Send and receive CAN frames over a serial connection.
Commands are encoded with MessagePack.
- Command: uint
- followed by an argument
| Commands | Argument | Explanation |
|---|---|---|
| 0x00 | MessagePack CAN frame | send CAN frame |
| 0x01 | CAN ID filter list | selectively receive CAN frames |
The MCU just forwards every CAN frame it receives encoded as described below.
A CAN frame is encoded as a MessagePack array with following entries:
| Order | Type | Explanation |
|---|
- | bool | IDE extended frame id flag
- | bool | RTR remote transmission request flag
- | uint | CAN ID (11bit or 29bit)
- | uint | DLC data length code, values: 0 - 8
- | bin | CAN frame data, length: 0 - 8 bytes
The filter list is a MessagePack array of at least one filter entry. One filter entry is composed of an ID with a corresponding mask and is encoded as a MessagePack array as following:
| Order | Type | Explanation |
|---|
- | bool | IDE extended frame id flag
- | bool | RTR remote transmission request flag
- | uint | CAN ID (11bit or 29bit)
- | bool | mask: IDE
- | bool | mask: RTR
- | uint | mask: ID
A mask bit set to 1 (or true) means the corresponding field has to match the given ID, 0 (or false) means the field doesn't matter. For a CAN frame to pass the filter it has to match at least one filter entry.