USB LIN Converter

v0.1.2
io.github.Lukasz-Juranek/lin-usb-converter Checked 10 hours ago Published 28 days ago

Sniff and reverse-engineer a car's LIN bus: capture, changing bits, speed detect, LDF decode

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

device_info

Converter port, firmware version, whether transmitting is allowed, and the loaded LDF (if any).

monitor_bus

Listen to the bus passively and summarize what is on it. Per frame id: count, period, last data, how many distinct values were seen and changing_bits (a per-byte mask of bits that changed). 'changes' lists every data change in time order, so asking the user to press a button during the capture shows which id and bit it drives. speed: 19200 (most cars), 10417 or 9600. checksum: 'enhanced' (LIN 2.x) or 'classic' (LIN 1.x); frames with the other checksum are dropped by the converter. ids: optional filter, e.g. ["0x0C"].

ParameterTypeDescription
checksumstring
duration_snumber
ids
speedinteger

detect_bus

Try every speed and checksum combination and report which one sees valid frames. Use when monitor_bus shows nothing on a live bus.

ParameterTypeDescription
seconds_per_trynumber

load_ldf

Load a LIN Description File so captures show signal names and values. Returns its frames and signals. Pass path "mock" with a --mock server to load the simulated bus's LDF.

ParameterTypeDescription
path *string

decode_frame

Decode raw frame bytes into signal values with the loaded LDF. id like "0x0C", data hex like "05 1e".

ParameterTypeDescription
data *string
id *string

encode_frame

Build frame bytes from signal values with the loaded LDF. Signals not given keep their LDF default. Returns id and data ready for send_frame.

ParameterTypeDescription
frame *string
signals *object

send_frame

Inject a complete frame (header + data) on the bus from monitor mode, `repeat` times about 20 ms apart, and capture the bus for a moment after. Needs --allow-transmit. The converter echoes only the header of its own frame back, so check the effect in the following traffic.

ParameterTypeDescription
data *string
id *string
checksumstring
repeatinteger
speedinteger

run_master

Act as the LIN master for duration_s: run a schedule that sends the `transmit` frames ([{"id": "0x0B", "data": "05"}]) and polls the `receive` ids ([{"id": "0x0C", "length": 2}]), then summarize the slave responses. Use only with the real master disconnected. Needs --allow-transmit.

ParameterTypeDescription
checksumstring
duration_snumber
receive
speedinteger
transmit

run_slave

Simulate a slave node for duration_s: answer the master's headers for the `respond` ids with fixed data ([{"id": "0x0C", "data": "01 1e"}]) and capture the `listen` ids the master sends ([{"id": "0x0B", "length": 1}]). Use only with the real slave disconnected. Needs --allow-transmit.

ParameterTypeDescription
checksumstring
duration_snumber
listen
respond
speedinteger