gmlan

package
v1.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 10 Imported by: 5 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

see GMW3110 gmw3110-2010.pdf

Index

Constants

View Source
const (
	TRANSFER_DATA                  = 0x36
	DEVICE_CONTROL                 = 0xAE
	DISABLE_NORMAL_COMMUNICATION   = 0x28
	INITIATE_DIAGNOSTIC_OPERATION  = 0x10
	PROGRAMMING_MODE               = 0xA5
	RETURN_TO_NORMAL_MODE          = 0x20
	REPORT_PROGRAMMED_STATE        = 0xA2
	READ_DATA_BY_IDENTIFIER        = 0x1A
	READ_DIAGNOSTIC_INFORMATION    = 0xA9
	READ_DATA_BY_PACKET_IDENTIFIER = 0xAA
	SECURITY_ACCESS                = 0x27
	REQUEST_DOWNLOAD               = 0x34
	WRITE_DATA_BY_IDENTIFIER       = 0x3B
	DYNAMICALLY_DEFINE_MESSAGE     = 0x2C
	READ_MEMORY_BY_ADDRESS         = 0x23
)
View Source
const (
	LEV_RSDTCBN = 0x80 /* readStatusOfDTCByDTCNumber                   */
	LEV_RSDTCBS = 0x81 /* readStatusOfDTCByStatusMask                  */
	LEV_SOCDTCC = 0x82 /* sendOnChangeDTCCount                         */
)

Variables

This section is empty.

Functions

func CheckErr

func CheckErr(frame *gocan.CANFrame) error

func DecodeDTC added in v1.0.7

func DecodeDTC(a, b byte) string

Example E1 03 -> 1110 0001 0000 0011 11=U

10=2
   0001=1
        0000=0
             0011=3

---------------------- U2103 DecodeDTC decodes a 2-byte DTC value (A,B) into a string like "P0122". Returns "" if both bytes are zero (often means "no code").

func DecodeDTCSlice added in v1.0.7

func DecodeDTCSlice(data []byte) string

DecodeDTCSlice expects at least two bytes and decodes the first two into a DTC string. Returns "" if the slice is too short or the DTC is zero.

func TranslateErrorCode

func TranslateErrorCode(p byte) string

func TranslateProgrammedState

func TranslateProgrammedState(state byte) string

func TranslateServiceCode

func TranslateServiceCode(p byte) string

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(c *gocan.Client, canID uint32, recvID ...uint32) *Client

func NewWithOpts

func NewWithOpts(client *gocan.Client, opts ...GMLanOption) *Client

func (*Client) ClearDiagnosticInformation added in v1.0.7

func (cl *Client) ClearDiagnosticInformation(ctx context.Context, id uint32) error

func (*Client) DeviceControl

func (cl *Client) DeviceControl(ctx context.Context, command byte) error

func (*Client) DeviceControlWithCode

func (cl *Client) DeviceControlWithCode(ctx context.Context, command byte, code []byte) error

func (*Client) DisableNormalCommunication

func (cl *Client) DisableNormalCommunication(ctx context.Context) error

8.9 DisableNormalCommunication ($28) Service.

The purpose of this service is to prevent a device from transmitting or receiving all messages which are not the direct result of a diagnostic request. The primary use of the service is to set up a programming event. This is a required service that must be supported by all nodes

func (*Client) DisableNormalCommunicationAllNodes

func (cl *Client) DisableNormalCommunicationAllNodes() error

AllNodes functional diagnostic request CANId ($101) and the AllNodes extended address ($FE).

func (*Client) DynamicallyDefineMessage

func (cl *Client) DynamicallyDefineMessage(ctx context.Context, ids ...uint16) error

8.10 DynamicallyDefineMessage ($2C) Service. This service is used to dynamically define the contents of diagnostic data packets which are formatted as UUDT messages and can be requested via the ReadDataByPacketIdentifier ($AA) service. The use of dynamic data packets allows a test device to optimize its diagnostic routines and bus bandwidth utilization by packing

func (*Client) Execute

func (cl *Client) Execute(ctx context.Context, startAddress uint32) error

func (*Client) InitiateDiagnosticOperation

func (cl *Client) InitiateDiagnosticOperation(ctx context.Context, level DiagnosticOperationLevel) error

func (*Client) ProgrammingMode

func (cl *Client) ProgrammingMode(ctx context.Context, subFunc byte) error

func (*Client) ProgrammingModeEnable

func (cl *Client) ProgrammingModeEnable(ctx context.Context) error

func (*Client) ProgrammingModeRequest

func (cl *Client) ProgrammingModeRequest(ctx context.Context) error

8.17 ProgrammingMode ($A5) Service.

This service provides for the following levels of operation: * Verifies that all criteria are met to enable the programming services for all receiving nodes. * Enables the high speed mode of operation (83.33 kbps) for all receiving nodes on the Single Wire CAN (SWCAN) bus (if high speed programming was requested by the tool). * Enables programming services for all receiving nodes. This service shall only be available if normal communications have already been disabled (via service $28)

subFunc 01 requestProgrammingMode

Request by the tester to verify the capability of the node(s) to enter into a normal speed
programming event.

02 requestProgrammingMode_HighSpeed

Request by the tester to verify the capability of the node(s) to enter into a high speed
programming event.

03 enableProgrammingMode

Request by the tester to have the node(s) enter into a programming event. This can only
be sent if preceded by one of the valid requestProgrammingMode messages (above).

func (*Client) ProgrammingModeRequestHighSpeed

func (cl *Client) ProgrammingModeRequestHighSpeed(ctx context.Context) error

func (*Client) ReadDataByIdentifier

func (cl *Client) ReadDataByIdentifier(ctx context.Context, pid byte) ([]byte, error)

func (*Client) ReadDataByIdentifierFrame

func (cl *Client) ReadDataByIdentifierFrame(ctx context.Context, frame *gocan.CANFrame) ([]byte, error)

func (*Client) ReadDataByIdentifierString

func (cl *Client) ReadDataByIdentifierString(ctx context.Context, pid byte) (string, error)

func (*Client) ReadDataByIdentifierUint16

func (cl *Client) ReadDataByIdentifierUint16(ctx context.Context, pid byte) (uint16, error)

8.4 ReadDataByIdentifier ($1A) Service.

The purpose of this service is to provide the ability to read the content of pre-defined ECU data referenced by a dataIdentifier (DID) which contains static information such as ECU identification data or other information which does not require real-time updates. (Real-time data is intended to be retrieved via the ReadDataByPacketIdentifier ($AA) service.)

func (*Client) ReadDataByPacketIdentifier

func (cl *Client) ReadDataByPacketIdentifier(ctx context.Context, subFunc byte, dpid ...byte) ([]byte, error)

8.19 ReadDataByPacketIdentifier ($AA) Service.

The purpose of the ReadDataByPacketIdentifier($AA) service is to allow a tester to request data packets that contain diagnostic information (e.g., sensor input or output values) which are packaged in a UUDT diagnostic message format. Refer to paragraph 4.5.1.2 for more information on UUDT diagnostic message format. Each diagnostic data packet includes one byte that contains a Data Packet IDentifier (DPID) number, and one to seven bytes of additional data. The DPID number occupies the message number byte position of the UUDT diagnostic response message and is used by the tester to determine the data contents of the remaining bytes of the message. This service is intended to be used to retrieve ECU data which is most likely changing during normal operation (e.g., ECU sensor inputs, ECU commanded output states, etc). Static information such as VIN or Part Numbers should be retrieved via the ReadDataByIdentifier ($1A) service. The DPIDs requested via this service can be sent as a one-time response or scheduled periodically. Each DPID scheduled can be transmitted at one of three predefined periodic rates (slow, medium, or fast). Periodic rates require a TesterPresent ($3E) message to be sent on the bus to keep the Periodic DPID Scheduler (PDS) active (reference $3E service description).

func (*Client) ReadDiagnosticInformation added in v1.0.7

func (cl *Client) ReadDiagnosticInformation(ctx context.Context, level DiagnosticInformationLevel, DTCMaskRecord ...byte) ([]DTC, error)

8.18 ReadDiagnosticInformation ($A9) Service.

This service allows a tester to read the status of node-resident Diagnostic Trouble Code (DTC) information from any controller, or group of controllers within a vehicle. This service allows the tester to do the following: 1. Retrieve the status of a specific DTC and FaultType combination. 2. Retrieve the list of DTCs that match a tester defined DTC status mask. 3. Enable a node resident algorithm which periodically calculates the number of DTCs that match a tester defined DTC status mask. The ECU shall send a response message each time the calculation yields a different result than the one calculated the previous time.

func (*Client) ReadDiagnosticInformationStatusOfDTCByStatusMask

func (cl *Client) ReadDiagnosticInformationStatusOfDTCByStatusMask(ctx context.Context, DTCStatusMask byte) ([]DTC, error)

ReadDiagnosticInformation $A9 Service

readStatusOfDTCByStatusMask $81 Request
    DTCStatusMask $12= 0001 0010
      0 Bit 7 warningIndicatorRequestedState
      0 Bit 6 currentDTCSincePowerUp
      0 Bit 5 testNotPassedSinceCurrentPowerUp
      1 Bit 4 historyDTC
      0 Bit 3 testFailedSinceDTCCleared
      0 Bit 2 testNotPassedSinceDTCCleared
      1 Bit 1 currentDTC
      0 Bit 0 DTCSupportedByCalibration

func (*Client) ReadMemoryByAddress

func (cl *Client) ReadMemoryByAddress(ctx context.Context, address, length uint32) ([]byte, error)

func (*Client) ReportProgrammedState

func (cl *Client) ReportProgrammedState(ctx context.Context) (byte, error)

8.16 ReportProgrammedState ($A2) Service.

The reportProgrammedState is used by the tester to determine: * Which nodes on the link are programmable. * The current programmed state of each programmable node.

func (*Client) RequestDownload

func (cl *Client) RequestDownload(ctx context.Context, z22se bool) error

8.12 RequestDownload ($34) Service. This service is used in order to prepare a node to be programmed

func (*Client) RequestSecurityAccess

func (cl *Client) RequestSecurityAccess(ctx context.Context, accesslevel byte, delay time.Duration, seedfunc func([]byte, byte) (byte, byte)) error

func (*Client) ReturnToNormalMode

func (cl *Client) ReturnToNormalMode(ctx context.Context) error

8.5 ReturnToNormalMode ($20) Service. The purpose of this service is to return a node or group of nodes to normal mode operation by canceling all active diagnostic services and resetting normal message communications (if they were interrupted by a diagnostic operation). All nodes participating in a GMLAN network shall support this service even if the node itself is diagnosed over another vehicle bus (e.g., KWP2000 or Class 2). This requirement is necessary to facilitate programming of other devices on the GMLAN subnet.

func (*Client) SecurityAccessRequestSeed

func (cl *Client) SecurityAccessRequestSeed(ctx context.Context, accessLevel byte) ([]byte, error)

8.8 SecurityAccess ($27) Service.

The purpose of this service is to provide a means to access data and/or diagnostic services which have restricted access for security, emissions, or safety reasons. Diagnostic modes for downloading routines or data into a node and reading specific memory locations from a node are situations where security access may be required. Improper routines or data downloaded into a node could potentially damage the electronics or other vehicle components or risk the vehicle’s compliance to emission, safety, or security standards. This mode is intended

func (*Client) SecurityAccessSendKey

func (cl *Client) SecurityAccessSendKey(ctx context.Context, accessLevel, high, low byte) error

func (*Client) TesterPresentNoResponseAllowed

func (cl *Client) TesterPresentNoResponseAllowed() error

func (*Client) TesterPresentResponseRequired

func (cl *Client) TesterPresentResponseRequired(ctx context.Context) error

8.15 TesterPresent ($3E) Service

This service is used to indicate to a node (or nodes) that a tester is still
connected to the vehicle and that certain diagnostic services that have been previously activated are to remain
active. Some diagnostic services require that a tester send a request for this service periodically in order to
keep the functionality of the other service active. Documentation within this specification of each diagnostic
service indicates if a given service requires the periodic TesterPresent request to remain active

func (*Client) TransferData

func (cl *Client) TransferData(ctx context.Context, subFunc byte, length byte, startAddress int) error

00 Download This sub-parameter level of operation is used to command a node to receive a block transfer and (only) download the data received to the memory address specified in the startingAddress[] parameter.

func (*Client) WriteDataByAddress

func (cl *Client) WriteDataByAddress(ctx context.Context, address uint32, data []byte) error

$15 - WDBA - Write Data By Address This service is used to write data to a memory location in the ECU. All memory locations start with $15 so this is just a apptool call path inside the WriteDataBIdentifier

func (*Client) WriteDataByAddress2 added in v1.0.7

func (cl *Client) WriteDataByAddress2(ctx context.Context, address uint32, data []byte) error

func (*Client) WriteDataByIdentifier

func (cl *Client) WriteDataByIdentifier(ctx context.Context, pid byte, data []byte) error

func (*Client) WriteDataByIdentifierUint16

func (cl *Client) WriteDataByIdentifierUint16(ctx context.Context, pid byte, value uint16) error

func (*Client) WriteDataByIdentifierUint32

func (cl *Client) WriteDataByIdentifierUint32(ctx context.Context, pid byte, value uint32) error

type DTC added in v1.0.7

type DTC struct {
	Code   string
	Status byte
}

type DiagnosticInformationLevel added in v1.0.7

type DiagnosticInformationLevel byte

type DiagnosticOperationLevel added in v1.0.7

type DiagnosticOperationLevel byte
const (
	LEV_DADTC DiagnosticOperationLevel = 0x02 /* disableAllDTCs                               */
	LEV_EDDDC DiagnosticOperationLevel = 0x03 /* enableDTCsDuringDevCntrl                     */
	LEV_WULNK DiagnosticOperationLevel = 0x04 /* wakeUpLinks                                 */
)

type GMError

type GMError struct {
	Service string
	Code    string
}

func (GMError) Error

func (e GMError) Error() string

type GMLanOption

type GMLanOption func(*Client)

func WithCanID

func WithCanID(canID uint32) GMLanOption

func WithDefaultTimeout

func WithDefaultTimeout(timeout time.Duration) GMLanOption

func WithRecvID

func WithRecvID(recvID ...uint32) GMLanOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL