t7kwp

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 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

Index

Constants

View Source
const (
	GENERAL_REJECT                                     = 0x10
	SERVICE_NOT_SUPPORTED                              = 0x11
	SUBFUNCTION_NOT_SUPPORTED_OR_INVALID_FORMAT        = 0x12
	BUSY_REPEAT_REQUEST                                = 0x21
	CONDITIONS_NOT_CORRECT_OR_REQUEST_SEQUENCE_ERROR   = 0x22
	ROUTINE_NOT_COMPLETE_OR_SERVICE_IN_PROGRESS        = 0x23
	REQUEST_OUT_OF_RANGE                               = 0x31
	SECURITY_ACCESS_DENIED_OR_REQUESTED                = 0x33
	INVALID_KEY                                        = 0x35
	EXCEED_NUMBER_OF_ATTEMPTS                          = 0x36
	REQUIRED_TIME_DELAY_NOT_EXPIRED                    = 0x37
	DOWNLOAD_NOT_ACCEPTED                              = 0x40
	IMPROPER_DOWNLOAD_TYPE                             = 0x41
	CANNOT_DOWNLOAD_TO_SPECIFIED_ADDRESS               = 0x42
	CANNOT_DOWNLOAD_NUMBER_OF_BYTES_REQUESTED          = 0x43
	UPLOAD_NOT_ACCEPTED                                = 0x50
	IMPROPER_UPLOAD_TYPE                               = 0x51
	CANNOT_UPLOAD_FROM_SPECIFIED_ADDRESS               = 0x52
	CANNOT_UPLOAD_NUMBER_OF_BYTES_REQUESTED            = 0x53
	TRANSFER_SUSPENDED                                 = 0x71
	TRANSFER_ABORTED                                   = 0x72
	ILLEGAL_ADDRESS_IN_BLOCK_TRANSFER                  = 0x74
	ILLEGAL_BYTE_COUNT_IN_BLOCK_TRANSFER               = 0x75
	ILLEGAL_BLOCK_TRANSFER_TYPE                        = 0x76
	BLOCK_TRANSFER_DATA_CHECKSUM_ERROR                 = 0x77
	REQUEST_CORRECTLY_RECEIVED_RESPONSE_PENDING        = 0x78
	INCORRECT_BYTE_COUNT_DURING_BLOCK_TRANSFER         = 0x79
	SERVICE_NOT_SUPPORTED_IN_ACTIVE_DIAGNOSTIC_SESSION = 0x80

	// Routine/transfer status codes. These are not failures, but they arrive in
	// the same byte position and callers report them as such.
	SECURITY_ACCESS_ALLOWED       = 0x34
	READY_FOR_DOWNLOAD            = 0x44
	READY_FOR_UPLOAD              = 0x54
	NORMAL_EXIT_WITH_RESULTS      = 0x61
	NORMAL_EXIT_WITHOUT_RESULTS   = 0x62
	ABNORMAL_EXIT_WITH_RESULTS    = 0x63
	ABNORMAL_EXIT_WITHOUT_RESULTS = 0x64
)
View Source
const (
	FAST_DOWN_ID uint32 = 0x7C0 // tester -> ECU data frames (EOL download)
	FAST_UP_ID   uint32 = 0x7C1 // ECU -> tester data frames (upload)

	RLI_FAST_INFO     = 0x60
	RLI_FAST_UPLOAD   = 0x61
	RLI_FAST_DOWNLOAD = 0x62
	RLI_FAST_COMMIT   = 0x63
)

Fast raw transfer: an extension in a modified T7 firmware, not in any SAAB release. Data frames carry 8 raw bytes with no KWP framing and no per-frame ack, so a transfer costs ~1/8 frame per byte instead of a round trip per 6 bytes. The old services are untouched; FastInfo tells whether an ECU has it.

View Source
const (
	READ_ECU_IDENTIFICATION = 0x1A // present in Trionic 7

	/* DATA TRANSMISSION FUNCTIONAL UNIT */
	READ_DATA_BY_COMMON_IDENTIFIER      = 0x22
	DYNAMICALLY_DEFINE_LOCAL_IDENTIFIER = 0x2C // present in Trionic 7
	WRITE_DATA_BY_LOCAL_IDENTIFIER      = 0x3B // present in Trionic 7
	WRITE_DATA_BY_COMMON_IDENTIFIER     = 0x2E
	SET_DATA_RATES                      = 0x26

	/* STORED DATA TRANSMISSION FUNCTIONAL UNIT */
	READ_DIAGNOSTIC_TROUBLE_CODES           = 0x13
	READ_DIAGNOSTIC_TROUBLE_CODES_BY_STATUS = 0x18 // present in Trionic 7
	READ_STATUS_OF_DIAGNOSTIC_TROUBLE_CODES = 0x17
	CLEAR_DIAGNOSTIC_INFORMATION            = 0x14 // present in Trionic 7

	/* INPUTOUTPUT CONTROL FUNCTIONAL UNIT */
	INPUT_OUTPUT_CONTROL_BY_COMMON_IDENTIFIER = 0x2F
	INPUT_OUTPUT_CONTROL_BY_LOCAL_IDENTIFIER  = 0x30 // present in Trionic 7

	/* REMOTE ACTIVATION OF ROUTINE FUNCTIONAL UNIT */
	REQUEST_ROUTINE_RESULTS_BY_LOCAL_IDENTIFIER = 0x33 // present in Trionic 7
	REQUEST_ROUTINE_RESULTS_BY_ADDRESS          = 0x3A

	STOP_REPEATED_DATA_TRANSMISSION = 0x25
	START_COMMUNICATION             = 0x81
	STOP_COMMUNICATION              = 0x82
	ACCESS_TIMING_PARAMETERS        = 0x83

	SYMBOL_IDENTIFICATION = 0x80

	/* Dynamically defined local identifier constants */
	DM_DBLI  = 0x01
	DM_DBMA  = 0x03
	DM_CDDLI = 0x04

	/* Start Routine by local ID definitions */
	// Define Debug frame contents
	RLI_DD = 0x40
	// Set operational mode
	RLI_DMC = 0x41
	// Read Mode status
	RLI_RM = 0x42
	// Read Debug frame contents
	RLI_RC = 0x43
	// Setup for symbol table reading
	RLI_SYM = 0x50
	// Setup for symbol table checksum
	RLI_CHSUM = 0x51
	// Start of EOL programming
	RLI_EOL_START = 0x52
	// Start erasing
	RLI_ERASE   = 0x53
	RLI_END_EOL = 0x54

	// Security access level
	NO_PRIORITY          = 0x00
	LOW_PRIORITY         = 0x01
	HIGH_PRIORITY        = 0x03
	DEVELOPMENT_PRIORITY = 0x05
)
View Source
const (
	START_COM_REQ                         = 0x81
	STOP_COM_REQ                          = 0x82
	START_DIAGNOSTIC_SESSION              = 0x10
	STOP_DIAGNOSTIC_SESSION               = 0x20
	ECU_RESET                             = 0x11
	READ_FREEZEFRAME_DATA                 = 0x12
	CLEAR_DTC                             = 0x14
	READ_STATUS_DTC                       = 0x17
	READ_DTC_BY_STATUS                    = 0x18
	READ_VEHICLE_IDENTIFICATION           = 0x1A
	READ_DATA_BY_IDENTIFIER               = 0x21
	READ_DATA_BY_IDENTIFIER_BIG           = 0x22
	READ_MEMORY_BY_ADDRESS                = 0x23
	SECURITY_ACCESS                       = 0x27
	DYNAMICALLY_DEFINE_IDENTIFIER         = 0x2C
	INPUT_OUTPUT_BY_IDENTIFIER            = 0x30
	START_ROUTINE_BY_IDENTIFIER           = 0x31
	STOP_ROUTINE_BY_IDENTIFIER            = 0x32
	REQUEST_ROUTINE_RESULTS_BY_IDENTIFIER = 0x33
	REQUEST_DOWNLOAD                      = 0x34
	REQUEST_UPLOAD                        = 0x35
	TRANSFER_DATA                         = 0x36
	REQUEST_TRANSFER_EXIT                 = 0x37
	START_ROUTINE_BY_ADDRESS              = 0x38
	STOP_ROUTINE_BY_ADDRESS               = 0x39
	WRITE_DATA_BY_IDENTIFIER              = 0x3B
	WRITE_DATA_BY_ADDRESS                 = 0x3D
	TESTER_PRESENT                        = 0x3E

	// Myrtilos specific
	EU0D_SET_REGISTRATION_KEY = 0x24
)
View Source
const (
	INIT_MSG_ID        uint32 = 0x220 // 220h
	INIT_RESP_ID       uint32 = 0x238 // 238h
	REQ_MSG_ID         uint32 = 0x240 // 240h
	RESP_CHUNK_CONF_ID uint32 = 0x266 // 266h
	REQ_CHUNK_CONF_ID  uint32 = 0x270 // 270h
)
View Source
const (
	NORMAL_MODE = 0
	DEBUG_MODE  = 1
	SILENT_MODE = 2
)

Variables

View Source
var (
	ErrGeneralReject                                = &Error{GENERAL_REJECT, "General reject"}
	ErrServiceNotSupported                          = &Error{SERVICE_NOT_SUPPORTED, "Service not supported"}
	ErrSubFunctionNotSupportedOrInvalidFormat       = &Error{SUBFUNCTION_NOT_SUPPORTED_OR_INVALID_FORMAT, "Sub-function not supported or invalid format"}
	ErrBusyRepeatRequest                            = &Error{BUSY_REPEAT_REQUEST, "Busy, repeat request"}
	ErrConditionsNotCorrectOrRequestSequenceError   = &Error{CONDITIONS_NOT_CORRECT_OR_REQUEST_SEQUENCE_ERROR, "Conditions not correct or request sequence error"}
	ErrRoutineNotCompleteOrServiceInProgress        = &Error{ROUTINE_NOT_COMPLETE_OR_SERVICE_IN_PROGRESS, "Routine not completed or service in progress"}
	ErrRequestOutOfRange                            = &Error{REQUEST_OUT_OF_RANGE, "Request out of range or session dropped"}
	ErrSecurityAccessDeniedOrRequested              = &Error{SECURITY_ACCESS_DENIED_OR_REQUESTED, "Security access denied"}
	ErrInvalidKey                                   = &Error{INVALID_KEY, "Invalid key supplied"}
	ErrExceedNumberOfAttempts                       = &Error{EXCEED_NUMBER_OF_ATTEMPTS, "Exceeded number of attempts to get security access"}
	ErrRequiredTimeDelayNotExpired                  = &Error{REQUIRED_TIME_DELAY_NOT_EXPIRED, "Required time delay not expired, you cannot gain security access at this moment"}
	ErrDownloadNotAccepted                          = &Error{DOWNLOAD_NOT_ACCEPTED, "Download (PC -> ECU) not accepted"}
	ErrImproperDownloadType                         = &Error{IMPROPER_DOWNLOAD_TYPE, "Improper download (PC -> ECU) type"}
	ErrCannotDownloadToSpecifiedAddress             = &Error{CANNOT_DOWNLOAD_TO_SPECIFIED_ADDRESS, "Unable to download (PC -> ECU) to specified address"}
	ErrCannotDownloadNumberOfBytesRequested         = &Error{CANNOT_DOWNLOAD_NUMBER_OF_BYTES_REQUESTED, "Unable to download (PC -> ECU) number of bytes requested"}
	ErrUploadNotAccepted                            = &Error{UPLOAD_NOT_ACCEPTED, "Upload (ECU -> PC) not accepted"}
	ErrImproperUploadType                           = &Error{IMPROPER_UPLOAD_TYPE, "Improper upload (ECU -> PC) type"}
	ErrCannotUploadFromSpecifiedAddress             = &Error{CANNOT_UPLOAD_FROM_SPECIFIED_ADDRESS, "Unable to upload (ECU -> PC) for specified address"}
	ErrCannotUploadNumberOfBytesRequested           = &Error{CANNOT_UPLOAD_NUMBER_OF_BYTES_REQUESTED, "Unable to upload (ECU -> PC) number of bytes requested"}
	ErrTransferSuspended                            = &Error{TRANSFER_SUSPENDED, "Transfer suspended"}
	ErrTransferAborted                              = &Error{TRANSFER_ABORTED, "Transfer aborted"}
	ErrIllegalAddressInBlockTransfer                = &Error{ILLEGAL_ADDRESS_IN_BLOCK_TRANSFER, "Illegal address in block transfer"}
	ErrIllegalByteCountInBlockTransfer              = &Error{ILLEGAL_BYTE_COUNT_IN_BLOCK_TRANSFER, "Illegal byte count in block transfer"}
	ErrIllegalBlockTransferType                     = &Error{ILLEGAL_BLOCK_TRANSFER_TYPE, "Illegal block transfer type"}
	ErrBlockTransferDataChecksumError               = &Error{BLOCK_TRANSFER_DATA_CHECKSUM_ERROR, "Block transfer data checksum error"}
	ErrRequestCorrectlyReceivedResponsePending      = &Error{REQUEST_CORRECTLY_RECEIVED_RESPONSE_PENDING, "Response pending"}
	ErrIncorrectByteCountDuringBlockTransfer        = &Error{INCORRECT_BYTE_COUNT_DURING_BLOCK_TRANSFER, "Incorrect byte count during block transfer"}
	ErrServiceNotSupportedInActiveDiagnosticSession = &Error{SERVICE_NOT_SUPPORTED_IN_ACTIVE_DIAGNOSTIC_SESSION, "Service not supported in current diagnostics session"}
	ErrSecurityAccessAllowed                        = &Error{SECURITY_ACCESS_ALLOWED, "Security access allowed"}
	ErrReadyForDownload                             = &Error{READY_FOR_DOWNLOAD, "Ready for download"}
	ErrReadyForUpload                               = &Error{READY_FOR_UPLOAD, "Ready for upload"}
	ErrNormalExitWithResults                        = &Error{NORMAL_EXIT_WITH_RESULTS, "Normal exit with results available"}
	ErrNormalExitWithoutResults                     = &Error{NORMAL_EXIT_WITHOUT_RESULTS, "Normal exit without results available"}
	ErrAbnormalExitWithResults                      = &Error{ABNORMAL_EXIT_WITH_RESULTS, "Abnormal exit with results"}
	ErrAbnormalExitWithoutResults                   = &Error{ABNORMAL_EXIT_WITHOUT_RESULTS, "Abnormal exit without results"}
)
View Source
var DefaultTimeout = 200 * time.Millisecond
View Source
var KnownSeedKeys = []SeedKey{
	{XOR: 0x8142, Sub: 0x2356},
	{XOR: 0x4081, Sub: 0x1F6F},
}

KnownSeedKeys are the XOR/SUB pairs found in stock T7 firmware, tried in order. An ECU flashed with a patched algorithm answers to none of them — recover its pair from the binary with pkg/widgets/seedkey.

Functions

func FastSum

func FastSum(b []byte) uint32

FastSum is the checksum both ends compute over the data bytes: a position-weighted (Fletcher-style) sum, uint32 wrapping. Unlike a plain sum it changes when a frame is duplicated and another dropped.

func PadTesterSerial

func PadTesterSerial(serial string) []byte

PadTesterSerial space-pads a tester serial to 13 bytes, the width the ECU's buffer expects. Shorter values leave offsets 9..11 pointing at whatever the diagnostic buffer still held, which is exactly the input TesterSerialBlocked has to reason about — so pad first, then check, then send the padded value.

func TesterSerialBlocked

func TesterSerialBlocked(serial []byte) bool

TesterSerialBlocked reports whether writing serial as PI-area field 0x98 would make the ECU erase its own flash and halt — recoverable only over BDM. Never send a 0x98 that this returns true for.

func TranslateErrorCode

func TranslateErrorCode(p byte) error

func TranslateServiceID

func TranslateServiceID(command byte) string

Types

type Client

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

func New

func New(c *gocan.Bus) *Client

func (*Client) Ack

func (t *Client) Ack(ctx context.Context, val byte, expectReply bool) error

Ack confirms a received response frame on 0x266 (0x3F on the 3rd byte). expectReply hints buffered (ELM/STN) adapters that another response frame follows; the last frame of a response is acked with expectReply false.

func (*Client) ClearDTCS

func (t *Client) ClearDTCS(ctx context.Context) error

func (*Client) ClearDynamicallyDefineLocalId

func (t *Client) ClearDynamicallyDefineLocalId(ctx context.Context) error

func (*Client) DynamicallyDefineLocalIdByAddress

func (t *Client) DynamicallyDefineLocalIdByAddress(ctx context.Context, index int, address uint32, length uint16) error

func (*Client) DynamicallyDefineLocalIdByLocID

func (t *Client) DynamicallyDefineLocalIdByLocID(ctx context.Context, index int, locID int) error

func (*Client) DynamicallyDefineLocalIdBySymbolNumber

func (t *Client) DynamicallyDefineLocalIdBySymbolNumber(ctx context.Context, index int, symbolNumber int) error

func (*Client) EndEOL

func (t *Client) EndEOL(ctx context.Context) error

EndEOL closes an EOL programming session (startRoutine 0x54). The ECU verifies the ROM checksum against the stored PI-area value and sets the EOL-success flag; it is only needed for a full EOL run, not an image reflash.

The ECU only accepts it once its procedurecheck mask is complete (ALL_CHECKED) — erase, flashcode, transfer start/exit, Delco HW numbers, VIN, programming date and tester serial. Anything missing yields conditionsNotCorrect; on any failure the routine results are appended raw, as the status byte layout for 0x54 is not pinned down.

func (*Client) EraseFlash

func (t *Client) EraseFlash(ctx context.Context, tick func()) error

EraseFlash runs the EOL erase: startRoutine EOLProgrammingStart (0x52), then EOLEraseFlash (0x53) — a chip-wide erase that takes ~20 s — then polls testerPresent until the ECU answers again. tick, when non-nil, is called once per poll so callers can drive a progress bar.

The erase is chip-wide, so afterwards requestDownload may target any address.

func (*Client) FastDownloadBlock

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

FastDownloadBlock programs one block during EOL, after EraseFlash, with startRoutine 0x62 (arm: address, length), the data as raw frames on FAST_DOWN_ID, then 0x63 (commit: FastSum). The ECU programs the block only when byte count and checksum match, and receives the next block while this one programs. address and len(data) must be even and len(data) at most the FastInfo block.

On error the block was either not programmed or programmed with this same data (commit reply lost), so resending it is always safe: flash only clears bits, and identical data clears none.

func (*Client) FastInfo

func (t *Client) FastInfo(ctx context.Context) (block int, ok bool, err error)

FastInfo probes for the fast transfer routines with startRoutine 0x60. Stock firmware refuses it with a negative response: ok is false and err nil. block is the largest FastDownloadBlock the ECU accepts.

Probe in a normal session, before EOLProgrammingStart: the EOL code that runs from RAM is the firmware currently in flash, so this also tells whether the flash can use FastDownloadBlock. A stock ECU in EOL aborts on the probe.

func (*Client) FastUpload

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

FastUpload reads length bytes from address with startRoutine 0x61: the ECU streams them as raw 8-byte frames on FAST_UP_ID (last one zero padded), then answers 71 61 with the FastSum of the data. Needs security access level 05 and a stopped engine. A dropped, duplicated or stale frame fails the read; resend it. Any new request stops a running upload in the ECU.

func (*Client) ReadDTCByStatus

func (t *Client) ReadDTCByStatus(ctx context.Context, status byte) ([]DTC, error)

ReadDTCByStatus reads stored DTCs (service 0x18). It is a plain read, so a timed-out exchange is simply requested again: the ECU drops an unacked reply after 400 ms (its T1 timeout), and a fresh request resets its transmit state anyway. One lost or late frame no longer fails the read.

func (*Client) ReadDataByIdentifier

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

func (*Client) ReadDataByLocalIdentifierMode

func (t *Client) ReadDataByLocalIdentifierMode(ctx context.Context, id, mode byte) ([]byte, error)

func (*Client) ReadECUIdentification

func (t *Client) ReadECUIdentification(ctx context.Context, id byte) ([]byte, error)

ReadECUIdentification reads one ECU identification field (service 0x1A) — the PI-area entries: VIN 0x90, part number 0x91, engine type 0x97 and friends.

func (*Client) ReadFlash

func (t *Client) ReadFlash(ctx context.Context, addr, length int) ([]byte, error)

func (*Client) ReadMemoryByAddress

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

func (*Client) ReadMemoryByAddressF0

func (t *Client) ReadMemoryByAddressF0(ctx context.Context, address, length int) ([]byte, error)

func (*Client) ReadRAM

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

func (*Client) ReadROM

func (t *Client) ReadROM(ctx context.Context, address, sramOffset uint32, length uint32) ([]byte, error)

func (*Client) RequestDownload

func (t *Client) RequestDownload(ctx context.Context, address uint32, length uint32) error

RequestDownload anchors the ECU's write pointer (service 0x34). The ECU accepts a fresh requestDownload mid-stream, so a failed block can resume from its failure point instead of restarting.

func (*Client) RequestRoutineResultsByLocalIdentifier

func (t *Client) RequestRoutineResultsByLocalIdentifier(ctx context.Context, id byte) ([]byte, error)

func (*Client) RequestSecurityAccess

func (t *Client) RequestSecurityAccess(ctx context.Context, force bool) (bool, error)

RequestSecurityAccess tries the stock seed/key pairs at development priority, pausing 3 s after each failed exchange. It stops early when the ECU refuses any further attempt for now, and the error wraps the last exchange's error.

func (*Client) RequestSeed

func (t *Client) RequestSeed(ctx context.Context, level byte) (uint16, error)

RequestSeed asks for a securityAccess seed at the given level without answering it, leaving the ECU locked.

func (*Client) RequestTransferExit

func (t *Client) RequestTransferExit(ctx context.Context) error

func (*Client) RequestUpload

func (t *Client) RequestUpload(ctx context.Context, address, length uint32) error

func (*Client) ResetECU

func (t *Client) ResetECU(ctx context.Context) error

ResetECU asks for a power-on reset (service 0x11, 0x01). Security access does not survive it.

func (*Client) SaveRAM

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

func (*Client) SecurityAccess

func (t *Client) SecurityAccess(ctx context.Context, level byte, k SeedKey) (bool, error)

SecurityAccess runs one seed/key exchange at the given level (0x01/0x03/0x05; 0x05 is what grants flash programming on a shipping T7). A rejected key is returned as an error, not (false, nil). An ECU already unlocked at level hands out seed 0000; that is reported as granted and no key is sent.

func (*Client) SendEU0DRegistrationKey

func (t *Client) SendEU0DRegistrationKey(ctx context.Context, key []byte) error

func (*Client) SendEU0DRegistrationKeyLong

func (t *Client) SendEU0DRegistrationKeyLong(ctx context.Context, key []byte) error

func (*Client) SetResponseID

func (t *Client) SetResponseID(id uint32)

func (*Client) SetSeedKey

func (t *Client) SetSeedKey(sk *SeedKey)

SetSeedKey sets an optional custom seed/key pair, tried before the stock KnownSeedKeys in RequestSecurityAccess. A nil pair clears it.

func (*Client) StartRoutineByIdentifier

func (t *Client) StartRoutineByIdentifier(ctx context.Context, id byte, extra ...byte) error

func (*Client) StartSession

func (t *Client) StartSession(ctx context.Context, id, responseID uint32) error

func (*Client) StartSession2

func (t *Client) StartSession2(ctx context.Context, id, responseID uint32) error

func (*Client) StopRoutineByIdentifier

func (t *Client) StopRoutineByIdentifier(ctx context.Context, id byte) ([]byte, error)

func (*Client) StopSession

func (t *Client) StopSession(ctx context.Context) error

StopSession ends the diagnostic session (stopCommunication, service 0x82). The KWP length is 1: the service has no parameters. Security access ends with the session.

func (*Client) TesterPresent

func (t *Client) TesterPresent(ctx context.Context) error

func (*Client) TransferData

func (t *Client) TransferData(ctx context.Context, length uint32) ([]byte, error)

func (*Client) TransferDataBlock

func (t *Client) TransferDataBlock(ctx context.Context, data []byte) error

TransferDataBlock sends one transferData (0x36) block: the whole block is a single KWP message split across frames, and only the last frame is answered (0x76 on the response id). Blocks are limited to 254 bytes by the one-byte KWP length; the flash path uses 128 to match TrionicCANLib.

busyRepeatRequest is answered by resending the identical block, never by re-anchoring with requestDownload. A busy ECU keeps the refused block in its programming buffer and points its receive buffer at a trash buffer, then programs the kept copy when the resend arrives. A requestDownload sent instead is read from that kept buffer: the block's first data bytes become the download address. That aborted EOL on a real flash, when a short tail block (2 frames) caught the ECU still programming the 128-byte block before it.

func (*Client) WriteDataByAddress

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

func (*Client) WriteDataByLocalIdentifier

func (t *Client) WriteDataByLocalIdentifier(ctx context.Context, id byte, data []byte) error

WriteDataByLocalIdentifier writes one PI-area field (service 0x3B). The EOL tail uses it for VIN 0x90, programming date 0x99 and tester serial 0x98; the ECU stores it with writePIArea(id, len(data), data).

A tester serial (id 0x98) that TesterSerialBlocked refuses is never sent: the ECU erases its flash and halts on one.

type DTC

type DTC struct {
	Code   string
	Status byte
}

DTC is one diagnostic trouble code as the T7 reports it: the 2-byte SAE code rendered as "Pxxxx" and the raw KWP status byte. T7 DTCs carry no failure-type suffix on the wire (unlike GMLAN).

type Error

type Error struct {
	Code byte
	Msg  string
}

func (*Error) Error

func (k *Error) Error() string

type Request

type Request struct{}

func NewRequest

func NewRequest(data []byte) *Request

type SeedKey

type SeedKey struct{ XOR, Sub uint16 }

SeedKey is a securityAccess (service 0x27) algorithm: key = ((seed<<2) ^ XOR) - Sub.

Jump to

Keyboard shortcuts

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