Skip to content

Documentation

Send and Receive LIN Frames

Master transmission and requests, slave responses and slave reception.

Send and Receive LIN Frames

Four basic LIN use cases

Master TX – Send data

The master transmits a complete LIN frame with identifier and payload.

Example: identifier 0x12, payload 11 22 33 44.

python examples/runtime/python_basic.py master-send 0x12 11223344

Parameters:

master-send   Send a LIN frame as master
0x12          LIN identifier
11223344      Payload bytes 11 22 33 44

The microcontroller generates the break, sync, PID, data and checksum.

Master RX – Request data from a slave

The master sends a LIN header. The addressed slave then supplies the payload.

Request four bytes for identifier 0x22:

python examples/runtime/python_basic.py master-request 0x22 4

Parameters:

master-request  Request slave response
0x22            LIN identifier
4               Expected number of payload bytes

Example output:

11 22 33 44

Slave TX – Respond to a master

The HAT can prepare a response that is sent automatically when a matching master header arrives.

python examples/runtime/python_basic.py slave-set 0x22 11223344

Parameters:

slave-set      Configure slave response
0x22           LIN identifier
11223344       Response bytes 11 22 33 44

The response remains active until changed or cleared.

Disable the response:

python examples/runtime/python_basic.py slave-clear

Slave RX – Receive data published by the master

Configuration and data retrieval are separate operations.

First configure which frame to receive:

python examples/runtime/python_basic.py slave-rx-set 0x12 8

This configures reception of eight payload bytes for identifier 0x12.

Then fetch a received frame:

python examples/runtime/python_basic.py slave-rx-recv

If no frame is available yet:

no frame

This separation matters: the microcontroller can receive a LIN frame even while the Linux application is not actively accessing the bus.

Checksum

The examples use the enhanced checksum by default.

For the classic checksum:

python examples/runtime/python_basic.py master-send 0x12 11223344 --classic

The same --classic option can be used with the corresponding request and slave commands.

Changing the baud rate

The default configuration uses 19200 bit/s.

The native LIN core currently supports:

1000 ... 20000 bit/s

Change the baud rate for the current session

Runtime operation INIT has code 0x01, followed by a four-byte little-endian baud rate.

Example for 9600 bit/s on LIN1 / master:

from beiis_lin.client import DaemonClient

c = DaemonClient()

baud = 9600
request = b"\x01" + baud.to_bytes(4, "little")

c.set_active_instance(0)          # master_tx_query
c.data_send(0, request)

_, _, reply = c.data_recv(
    instance=1,                  # master_rx_query
    channel=0,
    timeout=2.0,
)

print(reply.hex(" "))            # 01 00 = INIT succeeded
c.close()

For LIN2 / slave, the standard slots are 3 and 4:

TX query: Slot 3
RX query: Slot 4

This setting remains active until the native worker is restarted.

Change the baud rate persistently

For a persistent setting, modify the native worker’s configuration.

Example: master_native at 9600 bit/s:

from beiis_lin.client import DaemonClient

c = DaemonClient()

c.runtime_call("stop", {"name": "master_native"})

c.runtime_call(
    "instance_configure",
    {
        "name": "master_native",
        "config": {
            "tx_peer": "master_tx_query",
            "rx_peer": "master_rx_query",
            "lin_channel": 1,
            "baud": 9600,
        },
    },
)

c.runtime_call("start", {"name": "master_native"})
c.close()

The configuration is stored in the STM32 file system and therefore survives a reboot.

For slave_native, use lin_channel: 2 and the peers slave_tx_query and slave_rx_query.

Default channel assignment

The standard runtime uses:

LIN1   master_native
LIN2   slave_native

This is a software configuration, not a fixed hardware limitation assigning master or slave mode to a particular channel.

The internal query paths are explained in Runtime & Queries.