Baby LIN

Support for the LIN protocol is provided via the BabyLIN™ USB adapter. The adapter connects to the RT host via a USB port and provides the functionality of either a LIN master node or LIN slave node.

Similar to the CAN bus, the LIN protocol allows transfer of 8 byte message associated to an ID. The ID is 1 byte and the values for the ID are between 0 and 63.

RTDB items can be mapped to multi bit/byte fields defined on the 8 byte buffer payload.

Reference Information BabyLIN

I/O Card Model Number

CS-Baby-LIN-x.

I/O Driver Model Number

Provided via kernel usbserial.

I/O Module License:

ICS-SWB-1252.

NODE Configuration

In LIN terminology, LIN nodes either publish a frame or subscribe to a frame. A frame publisher is responsible for generating the frame content while a frame subscriber is interested in receiving the specific frame to read its content. Master and slave nodes can both be publisher and subscriber of frames. However, there can only be a single publisher of a specific frame on a LIN network.

Buttons

Expand All expandall00021.png

Expands the hierarchy tree showing board configuration.

Collapse All collapseall00022.png

Collapses the hierarchy tree showing the board configuration to show only the channel nodes.

New ID

Adds a new LIN frame ID under the selected subscriber/publisher branch.

Delete

Deletes the selected frame ID and everything, including mappings, below it.

Speed bits/s

Select the speed at which this Baby LIN will connect to the LIN network. Auto detect can only be specified for a slave node.

LIN Master

Specify that this BabyLIN node is a LIN master.

OS Device

Specify the OS device to use for this specific Baby LIN device. Support to access the device is provided by the RedHawk kernel via the usbserial device. Typical name for the OS device is /dev/ttyUSBx where x is a number starting at 0 for the first Baby LIN device. This number may vary if you have other USB serial devices installed in your system. The ttyUSBx name must be unique for each Baby LIN device, when multiple Baby LIN devices are being used.
Note: The device name can change if the system configuration changes. For example, when a new USB device is installed.

LIN Frame Configuration

Frame ID

The message identifier. This is a 6-bit value, The maximum value allowed is 63.

FIFO

Specifies that the message is transmitted as soon as it changes. For output messages only.

TX on change

When a message is defined as FIFO and TX on change is set, the output frame is sent as soon as the content change, when TX on change is not set, the frame is only sent on user request via an API call.

Sched Rate (ms)

The rate in milliseconds at which transmission/polling is scheduled. Contrary to the CAN network. Input messages (subscriber) need to be retrieved from the LIN slaves by the master node. Thus, the schedule rate must also be specified for subscribed messages.

Message Length

The number of bytes in the message (maximum 8).

LIN Version

The LIN protocol version for the frame. Either 1.2/1.3 or 2.0, The protocol will determine how the checksum on the message content is calculated.

New Field

Adds a new data field for RTDB mapping to the selected frame.

Delete

Deletes the selected field including mappings.

Message Field Definition

You map RTDB item to a LIN message by creating new fields byte/bit fields within the frame. Each individual field has a raw data type - Packed,int,float,etc. that can be map to individual RTDB items by selecting the field and clicking on the checkbox next to the item name in the right panel.

Raw Type

How to interpret the raw bits of the field.

Packed

Integer bit field. Location is specified by the Bit setting.

char

One-byte integer. Location is specified by the Byte setting.

short

Two-byte integer. Location is specified by the Byte setting.

int

Four-byte integer. Location is specified by the Byte setting.

float

Four-byte floating-point number. Location is specified by the Byte setting.

double

Eight-byte floating-point number. Location must be specified as 0 by the Byte setting.

Byte (offset)

Byte offset within the 8-byte data of the non-bit field data.

Bit (offset:size)

Bit offset and number of bits to reserve for the field within the 64-bit data of the message.

Big Endian

Interprets the bytes as most significant byte first.

Assigning BabyLIN Device Node

To avoid the possibility of the BabyLIN USB device assignment changing upon reboot, you can use udev to specify the device node that is created in the /dev directory. The following steps describe how to automatically generate a symbolic link to /dev/ttyUSB0 from /dev/babyLIN0. If you have more BabyLIN devices, simply change the device number suffix as appropriate.

 

Synchronous I/O Task: babylinout

This process packs all BabyLIN raw output values corresponding to LIN output frames and places them in the BabyLIN output FIFO queue. The process will not queue a request into the FIFO queue if the raw LIN message is unchanged since the last test cycle.

The FIFO queue is read by the babylinasyncio asynchronous task which in turns reads from and writes to the Baby LIN device.