CAN and DBC¶
This project uses a DBC-driven workflow to encode/decode CAN frames consistently across the RX and TX targets.
Sources and generated code¶
DBC source:
tools/Lecture.dbcGenerated C wrapper (do not edit):
lib/Generated/lib/lecture.{c,h}Single include in the project:
src/generated_lecture_dbc.c(pulls in the generated library)
Note: the generator produces a driver named lecture (that’s the -drvname value used here). Include
lib/Generated/lib/lecture.h in your code to get the generated types and helper functions (for example
Cluster_t, Pack_Cluster_lecture(...), Unpack_Cluster_lecture(...)). The project also provides
src/generated_lecture_dbc.c which includes the generated C file directly for the build.
Driver abstraction lives under lib/CanDriver/ and supports the ESP32 internal CAN controller and common external controllers.
Regenerating from DBC (Windows)¶
Ensure the DBC is saved at
tools/Lecture.dbc.Run the generator (Windows only, provided in repo):
Tool:
tools/c-coderdbc/build/coderdbc.exeOutput folder (autodetected by script):
lib/Generated/(subfolders are managed by the generator)Example (Windows, run from the repository root):
tools\c-coderdbc\build\Debug\coderdbc.exe -dbc tools\Lecture.dbc -out lib\Generated -drvname lecture -rw
Commit the updated files under
lib/Generated/.
The code should always use the generated types and pack/unpack helpers:
Type:
Cluster_tPack:
Pack_Cluster_lecture(...)Unpack:
Unpack_Cluster_lecture(...)
RX mailbox and topics¶
RX config: mailbox filter listening to ID
0x65viaCAN0.watchFor(0x65)Data flow: ISR → EventQueue → SystemController → MessageRouter → UI/IOModule
Router publishes
Cluster_twith sticky last value and a millis() timestamp. Consumers subscribe to receive updates.
TX specifics¶
No LVGL; keep
CAN0.setDebuggingMode(true)during developmentSend
Cluster_tusingPack_Cluster_lectureon each cycle
See also ARCHITECTURE.md for the broader system overview and include/TFTConfiguration.h for display configuration (RX only).