gmlan

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: MIT Imports: 11 Imported by: 5

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_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
)

Variables

View Source
var ErrRetry = errors.New("retry")

Functions

func CheckErr

func CheckErr(frame *gocan.CANFrame) error

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) 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, subFunc byte) error

8.2 InitiateDiagnosticOperation ($10) Service.

This service allows the tester to perform the following tasks: * Disable the setting of all DTCs while the tool continues to perform other diagnostic services. * Allow ECU DTC algorithms to continue to execute while the DeviceControl ($AE) service is active. * Request a gateway ECU to issue a wake-up request.

  • 02 disableAllDTCs This level shall disable setting of all DTCs.
  • 03 enableDTCsDuringDevCntrl This level shall be used to allow DTC algorithms to continue to execute while the DeviceControl ($AE) service is active. This request shall have to be made prior to activating DeviceControl or the request shall be rejected. If this service and level are not requested before entering DeviceControl, then DTCs shall be inhibited while DeviceControl is active. (See the $AE service for further details). Note: If another diagnostic service is requested which disables DTCs (after the request is sent to allow DTCs to run during DeviceControl) then the DTCs shall become inhibited and remain inhibited until after a TesterPresent timeout occurs or a $20 service is requested.
  • 04 wakeUpLinks This level shall cause a gateway ECU to initiate the appropriate wake-up sequence on all GMLAN subnets that it is connected to (provided that a given subnet has a wake-up mechanism defined). Note: The rules for sending a wake-up as defined in GMW 3104 - GMLAN Communications Strategy Specification still apply (e.g., the strategy specification restricts wake-up requests to have a minimum time interval between them. If a diagnostic request is received to initiate a wake-up and the minimum interval has not expired, then the ECU shall send the positive response message back to the tester without initiating another wake-up). If a GMLAN subnet uses a shared local input as a wake-up wire and the shared local input has to remain asserted to keep communications active, then the gateway device shall ensure that the wake-up wire is asserted while the gateways diagnostic VN is active. Note: An example of the shared local input wake-up mechanism described above would be a gateway that is connected to both the single wire CAN link and a dual wire CAN link. In this example, the gateway uses a relay to switch power to the other devices on the dual wire CAN subnet. For normal operations the gateway would receive the High Voltage wake-up on the single wire CAN bus and then enable the relay to provide power to the dual wire devices. If the ECU receives a request for this service with the wakeUpLinks ($04) sub-function parameter, then the ECU would ensure that the relay providing power to the dual wire link ECUs remains enabled as long as the diagnostic VN is active in the gateway (or longer if the ECU would otherwise keep t

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) ReadDiagnosticInformationStatusOfDTCByStatusMask

func (cl *Client) ReadDiagnosticInformationStatusOfDTCByStatusMask(ctx context.Context, DTCStatusMask byte) ([][]byte, 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

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 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