lin

package
v0.751.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package lin decodes a LIN (Local Interconnect Network) bus frame — the low-cost single-wire automotive sub-bus that hangs off CAN for body electronics: door / mirror / seat modules, climate flaps, wiper and rain/light sensors, switch panels. It is a real automotive reverse-engineering / pentest surface (cheap to tap, often unauthenticated) and is distinct from the CAN family the other automotive decoders cover.

Wrap-vs-native judgement

Native. A LIN frame is a fully-public fixed structure (LIN 2.x /
ISO 17987): an optional 0x55 sync byte, a Protected Identifier
(PID = 6-bit frame ID + 2 parity bits), 1-8 data bytes, and a
checksum. The PID parity is two XOR equations over the ID bits;
the checksum is the inverted carry-folded sum of the data (classic)
or of the PID + data (enhanced). All deterministic byte/bit math —
reimplemented from the standard, no new dependency, no shell-out.

What this covers

  • The Protected Identifier: the 6-bit frame ID, the parity bits, and a recompute of the parity (reported valid / invalid), plus a frame-class note (signal frame / master-request or slave-response diagnostic / user-defined / reserved).
  • The data bytes (length inferred as frame_length − PID − checksum).
  • The checksum: both the classic (data-only, LIN 1.x + diagnostics) and the enhanced (PID + data, LIN 2.x) forms are computed and the frame's checksum is reported as classic / enhanced / invalid.

Deliberately deferred

The signal (DBC/LDF) interpretation of the data bytes needs the
vehicle's LIN Description File and is not attempted — the raw data
is surfaced. The break field and bit-timing are physical-layer and
upstream of the captured bytes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	SyncByte      bool     `json:"sync_byte_present"`
	PID           string   `json:"pid"`
	FrameID       int      `json:"frame_id"`
	FrameIDHex    string   `json:"frame_id_hex"`
	ParityValid   bool     `json:"parity_valid"`
	ExpectedPID   string   `json:"expected_pid"`
	FrameClass    string   `json:"frame_class"`
	DataLength    int      `json:"data_length"`
	DataHex       string   `json:"data_hex,omitempty"`
	Checksum      string   `json:"checksum"`
	ChecksumType  string   `json:"checksum_type"`
	ChecksumValid bool     `json:"checksum_valid"`
	Notes         []string `json:"notes,omitempty"`
}

Result is the decoded LIN frame.

func Decode

func Decode(hexStr string) (*Result, error)

Decode parses a LIN frame from hex: an optional 0x55 sync byte, the PID, the data bytes, and the trailing checksum.

Jump to

Keyboard shortcuts

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