CAN bus message creation
This is a description of how to create a CAN message for driver and common block API.
CAN ID
By default, 3 bites of CAN ID are reserved for the Sender address. Other bits are for SID (Service ID).
note
With 3 bites for the address, there are maximum 8 devices o the CAN bus.
This can be changed, there are this possible solutions:
- It can be hardcoded in OEM FW
- It can be changed by command
msgconf 3 4 0 n
- Where `n` is bit count for sender address (more in yOS documentation)
Bit | Description |
---|---|
0 | Sender addr bit 0 |
1 | Sender addr bit 1 |
2 | Sender addr bit 2 |
3 | SID bit 0 |
4 | SID bit 1 |
5 | SID bit 2 |
... | |
Last bit 10 or 28 | Standard or extended CAN |
info
Sender address is usually 7, or any unused address.
CAN ID example
Sending message with SID 24 from address 7.
CAN ID = (24 << 3) + 7 = 192 + 7 = 199 (DEC) = 0xC7 (HEX)
CAN message data for unicast
Unicast (datagram contains receiver and sender address)
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
Multicast (datagram contains sender address only)
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 |