Working with the CAN Bus » History » Version 1
Adam Klama, 06/21/2026 03:03 PM
| 1 | 1 | Adam Klama | # Working with the CAN Bus |
|---|---|---|---|
| 2 | |||
| 3 | Several IO types exchange data over CAN. This page covers the shared concepts they |
||
| 4 | depend on; the per-IO pages cover the specifics. |
||
| 5 | |||
| 6 | > Schema: `Canbus`, `CanbusInputFrameDescription`, `CanbusOutputFrameDescription` |
||
| 7 | > and `CanbusEntityHandler` in `config/Config.proto`; the `canbusEntities/` |
||
| 8 | > folder holds the predefined **CAN Presets**. |
||
| 9 | |||
| 10 | ## CAN bus definition |
||
| 11 | Before adding any CAN IO you must have a CAN bus defined, with: |
||
| 12 | |||
| 13 | | Setting | Meaning | |
||
| 14 | |---|---| |
||
| 15 | | **CAN ID / bus** | Which physical CAN channel. | |
||
| 16 | | **Baud rate** | Bus speed (e.g. 500 kbit/s). | |
||
| 17 | | **CAN FD** | Enable FD and set the FD data baud rate, if used. | |
||
| 18 | | **Termination** | Enable the on-board 120 Ω terminator when the controller is an end node. | |
||
| 19 | |||
| 20 | ## Two ways to use CAN |
||
| 21 | |||
| 22 | ### 1. Raw frame signals |
||
| 23 | Decode/encode individual **CANbus signals** directly from raw CAN frames by hand. |
||
| 24 | Use these when you have a DBC or know the byte layout: |
||
| 25 | - **[CAN Bus Input](CAN_Bus_Input)** — extract a signal from an incoming |
||
| 26 | frame (message ID, endianness/bitfield, length, offset, scaling, timeout |
||
| 27 | behaviour). |
||
| 28 | - **[CAN Bus Output](CAN_Bus_Output)** — pack a signal into an outgoing |
||
| 29 | frame. |
||
| 30 | |||
| 31 | ### 2. CAN Presets |
||
| 32 | **CAN Presets** are predefined device profiles (dashes, ECUs, shifters, keypads, |
||
| 33 | paddles…) that live in `canbusEntities/`. A preset publishes/consumes a set of |
||
| 34 | named **CAN objects** and handles all the byte decoding/encoding for you. When you |
||
| 35 | add a preset it **automatically creates the matching object IO** — you reference |
||
| 36 | or drive those rather than hand-decoding bytes: |
||
| 37 | - **[CAN Object Input](CAN_Object_Input)** — a preset-created input |
||
| 38 | carrying a named object's value (not configured by hand). |
||
| 39 | - **[CAN Object Output](CAN_Object_Output)** — a named object the preset |
||
| 40 | sends, driven by a source value. |
||
| 41 | |||
| 42 | ## Choosing between them |
||
| 43 | - Use **raw frame signals** for arbitrary/custom devices where you know the layout. |
||
| 44 | - Use **CAN Presets** for supported devices — less error-prone, no manual byte math. |
||
| 45 | |||
| 46 | ## Timeouts (inputs) |
||
| 47 | CAN inputs define what to report if a frame stops arriving (`TimeoutMode`): |
||
| 48 | `UsePrevious`, `UseDefault`, or `UseFault`. Set a timeout for any safety-relevant |
||
| 49 | signal so a dropped frame is detected rather than silently held. |