Documentation
¶
Overview ¶
Package gmlan implements the GMLAN (GMW3110) diagnostic services on a gocan v2 bus. See gmw3110-2010.pdf.
Index ¶
- Constants
- func CheckErr(frame gocan.Frame) error
- func DecodeDTC(a, b byte) string
- func DecodeDTCSlice(data []byte) string
- func FailureTypeString(b byte) string
- func TranslateErrorCode(p byte) string
- func TranslateProgrammedState(state byte) string
- func TranslateServiceCode(p byte) string
- type Client
- func (cl *Client) ClearDiagnosticInformation(ctx context.Context, id uint32) error
- func (cl *Client) DeviceControl(ctx context.Context, command byte) error
- func (cl *Client) DeviceControlWithCode(ctx context.Context, command byte, code []byte) error
- func (cl *Client) DisableNormalCommunication(ctx context.Context) error
- func (cl *Client) DisableNormalCommunicationAllNodes() error
- func (cl *Client) DynamicallyDefineMessage(ctx context.Context, ids ...uint16) error
- func (cl *Client) Execute(ctx context.Context, startAddress uint32) error
- func (cl *Client) InitiateDiagnosticOperation(ctx context.Context, level DiagnosticOperationLevel) error
- func (cl *Client) ProgrammingMode(ctx context.Context, subFunc byte) error
- func (cl *Client) ProgrammingModeEnable(ctx context.Context) error
- func (cl *Client) ProgrammingModeRequest(ctx context.Context) error
- func (cl *Client) ProgrammingModeRequestHighSpeed(ctx context.Context) error
- func (cl *Client) ReadDataByIdentifier(ctx context.Context, pid byte) ([]byte, error)
- func (cl *Client) ReadDataByIdentifierFrame(ctx context.Context, frame gocan.Frame) ([]byte, error)
- func (cl *Client) ReadDataByIdentifierString(ctx context.Context, pid byte) (string, error)
- func (cl *Client) ReadDataByIdentifierUint16(ctx context.Context, pid byte) (uint16, error)
- func (cl *Client) ReadDataByPacketIdentifier(ctx context.Context, subFunc byte, dpid ...byte) ([]byte, error)
- func (cl *Client) ReadDiagnosticInformation(ctx context.Context, level DiagnosticInformationLevel, DTCMaskRecord ...byte) ([]DTC, error)
- func (cl *Client) ReadDiagnosticInformationStatusOfDTCByStatusMask(ctx context.Context, DTCStatusMask byte) ([]DTC, error)
- func (cl *Client) ReadMemoryByAddress(ctx context.Context, address, length uint32) ([]byte, error)
- func (cl *Client) ReportProgrammedState(ctx context.Context) (byte, error)
- func (cl *Client) RequestDownload(ctx context.Context, z22se bool) error
- func (cl *Client) RequestSecurityAccess(ctx context.Context, accesslevel byte, delay time.Duration, ...) error
- func (cl *Client) ReturnToNormalMode(ctx context.Context) error
- func (cl *Client) SecurityAccessRequestSeed(ctx context.Context, accessLevel byte) ([]byte, error)
- func (cl *Client) SecurityAccessSendKey(ctx context.Context, accessLevel, high, low byte) error
- func (cl *Client) TesterPresentNoResponseAllowed() error
- func (cl *Client) TesterPresentResponseRequired(ctx context.Context) error
- func (cl *Client) TransferData(ctx context.Context, subFunc byte, length byte, startAddress int) error
- func (cl *Client) WriteDataByAddress(ctx context.Context, address uint32, data []byte) error
- func (cl *Client) WriteDataByAddress2(ctx context.Context, address uint32, data []byte) error
- func (cl *Client) WriteDataByIdentifier(ctx context.Context, pid byte, data []byte) error
- func (cl *Client) WriteDataByIdentifierUint16(ctx context.Context, pid byte, value uint16) error
- func (cl *Client) WriteDataByIdentifierUint32(ctx context.Context, pid byte, value uint32) error
- func (cl *Client) WriteMemoryByAddress(ctx context.Context, address uint32, data []byte) error
- type DTC
- type DiagnosticInformationLevel
- type DiagnosticOperationLevel
- type GMError
- type GMLanOption
Constants ¶
const ( AccessLevel01 = 0x01 AccessLevelFB = 0xFB AccessLevelFD = 0xFD )
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 WRITE_MEMORY_BY_ADDRESS = 0x3D )
const ( LEV_RSDTCBN = 0x80 /* readStatusOfDTCByDTCNumber */ LEV_RSDTCBS = 0x81 /* readStatusOfDTCByStatusMask */ LEV_SOCDTCC = 0x82 /* sendOnChangeDTCCount */ )
Variables ¶
This section is empty.
Functions ¶
func DecodeDTC ¶
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 ¶
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 FailureTypeString ¶
FailureTypeString returns the GMW3110 Appendix E description of a DTCFailureTypeByte ("symptom"), e.g. 0x02 = "short to ground". The high nibble is the failure category (Table E3), the low nibble the sub type (Tables E4..E11); values the spec does not enumerate fall back to their category.
func TranslateErrorCode ¶
func TranslateServiceCode ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewWithOpts ¶
func NewWithOpts(client *gocan.Bus, opts ...GMLanOption) *Client
func (*Client) ClearDiagnosticInformation ¶
func (*Client) DeviceControl ¶
func (*Client) DeviceControlWithCode ¶
func (*Client) DisableNormalCommunication ¶
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 ¶
AllNodes functional diagnostic request CANId ($101) and the AllNodes extended address ($FE).
func (*Client) DynamicallyDefineMessage ¶
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
ids are the PIDs packed, in order, into DPID $FE, the first dynamic DPID.
func (*Client) InitiateDiagnosticOperation ¶
func (cl *Client) InitiateDiagnosticOperation(ctx context.Context, level DiagnosticOperationLevel) error
func (*Client) ProgrammingMode ¶
func (*Client) ProgrammingModeEnable ¶
func (*Client) ProgrammingModeRequest ¶
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 (*Client) ReadDataByIdentifier ¶
func (*Client) ReadDataByIdentifierFrame ¶
func (*Client) ReadDataByIdentifierString ¶
func (*Client) ReadDataByIdentifierUint16 ¶
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. Each diagnostic data packet includes one byte that contains a Data Packet IDentifier (DPID) number, and one to seven bytes of additional data. The DPIDs requested via this service can be sent as a one-time response or scheduled periodically.
func (*Client) ReadDiagnosticInformation ¶
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 (*Client) ReportProgrammedState ¶
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 ¶
8.12 RequestDownload ($34) Service. This service is used in order to prepare a node to be programmed
func (*Client) RequestSecurityAccess ¶
func (*Client) ReturnToNormalMode ¶
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 ¶
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.
func (*Client) SecurityAccessSendKey ¶
func (*Client) TesterPresentNoResponseAllowed ¶
func (*Client) TesterPresentResponseRequired ¶
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 ¶
$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
The request goes out as a first frame and consecutive frames even when it would fit a single frame: that is the form the apptool path is known to accept.
func (*Client) WriteDataByAddress2 ¶
func (*Client) WriteDataByIdentifier ¶
func (*Client) WriteDataByIdentifierUint16 ¶
func (*Client) WriteDataByIdentifierUint32 ¶
func (*Client) WriteMemoryByAddress ¶ added in v2.2.0
WriteMemoryByAddress ($3D) writes data to the node's memory starting at address, with the same 3-byte address as ReadMemoryByAddress. A request too long for a single frame goes out as a first frame and consecutive frames.
type DiagnosticInformationLevel ¶
type DiagnosticInformationLevel byte
type DiagnosticOperationLevel ¶
type DiagnosticOperationLevel byte
const ( LEV_DADTC DiagnosticOperationLevel = 0x02 /* disableAllDTCs */ LEV_EDDDC DiagnosticOperationLevel = 0x03 /* enableDTCsDuringDevCntrl */ LEV_WULNK DiagnosticOperationLevel = 0x04 /* wakeUpLinks */ )
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