CAN Bus Link Layer
This guide explains the link layer for CAN frames used by the YOS communication system. The link layer defines the device addressing and sevice identification. The construct can be used for the utility driver and common I/O API communication.
CAN ID
The CAN ID is composed of:
- n first bits for the Sender address
- remaining bits for to SID (Service ID)
The default allocation for the sender address is three bits.
Bit | Description |
---|---|
0 | Sender address bit 0 |
1 | Sender address bit 1 |
2 | Sender address bit 2 |
3 | SID bit 0 |
4 | SID bit 1 |
5 | SID bit 2 |
... | |
Last bit 10 or 28 | Standard or extended CAN |
Three address bits limit the CAN bus to 8 devices maximum. This limitation can be modified through:
- OEM firmware customization
- Configuring the CAN link layer decoding with
msgconf 3 4 0 n
- Where
n
specifies bit count for sender address (see yOS documentation)
- Where
If you do not follow the link layer structure, use the sender address with all bits set to one (e.g. 0b111 for n=3).
To send a message with SID 24 from address 7: CAN ID = (24 << 3) + 7 = 192 + 7 = 199 (DEC) = 0xC7 (HEX)
CAN Message Data for Unicast datagram
Unicast messages contain the receiver address in the first byte of the frame, before payload starts:
Byte | Description |
---|---|
0 | Receiver address |
1 | Payload byte 0 |
2 | Payload byte 1 |
3 | Payload byte 2 |
4 | Payload byte 3 |
5 | Payload byte 4 |
6 | Payload byte 5 |
7 | Payload byte 6 |
CAN Message Data for Multicast datagram
Multicast messages include only sender address
Byte | Description |
---|---|
0 | Payload byte 0 |
1 | Payload byte 1 |
2 | Payload byte 2 |
3 | Payload byte 3 |
4 | Payload byte 4 |
5 | Payload byte 5 |
6 | Payload byte 6 |
7 | Payload byte 7 |