DBC Parsing

Nobody wants to read hex codes and figure out what they mean, so we use DBC files! DBC files are used in industry to assign names, units, signed/unsigned flags, and hex → decimal conversion.

We autogenerate all our DBC files like the rest of our CAN using YAML files. To autogenerate, use this command: python3 libraries/codegen/generator.py -t system_can.dbc.jinja -f can/tools

We often use cantools [python can library] for DBC-specific commands to help debug issues in our vehicle. My personal favourite is: cantools monitor -c can0 can/tools/system_can.dbc We also use cantools in our Python scripts to extract data. This maintains the integrity of our Python scripts, as it is not CAN ID dependent (Very prone to changing).

To read more about these commands take a look at cantools: https://cantools.readthedocs.io/en/latest/

A brief introduction to DBC file syntax incase you want to customize your autogenerated one:

image-20240822-055640.png
image-20240822-060538.png

For our use case, we do not autogenerate a custom scale, offset or units. :

BO_ [CAN RAW ID] [MESSAGE NAME]: [LENGTH IN BYTES] [SENDER]

SG_ [SIGNAL NAME]: [STARTING BIT] | [BIT LENGTH]@[ENDIANESS] (SCALE, OFFSET) [MIN | MAX] "UNITS" [MESSAGE RECEIVERS]