This repository defines the messages on the CAN bus in the car in the form of a DBC database and provides various utilities for generating system configuration files and source code from its contents.
Generated configurations are stored in this repository in the /out folder.
Configurations are version controlled so that we can ensure each part of the
system is referring to the same configurations.
To use the generated configuration in a project, add this repo as a submodule. For example:
cd <LOCATION TO CLONE SUBMODULE>
git submodule add https://github.com/sufst/can-defsNote that the use of submodules will require the following commands to be run when cloning a project for the first time:
git submodule init
git submodule updateFor more information on submodules, see the Git submodule documentation.
DBC ("Data Base CAN") is an industry standard file format for defining the content of messages on a CAN bus. Many device vendors provide DBC files for the CAN traffic generated by their devices.
STAG 12 has two CAN buses:
- CAN-T ("tractive systems") bus.
- CAN-S ("sensor/non-critical systems") bus.
There are many tools for working with DBC files. We suggest the use of Vector CANdb++ which can be downloaded for free as part of the demo version of Vector CANAnalyzer (Windows only). Note also that DBC files can often be imported by CAN datalogger configuration software. We can use this for our MoTeC L120 datalogger to automatically configure the parsing and logging of CAN data.
TSGEN is a Python module which generates various parts of the telemetry system based on the DBC for the car. This includes:
- C source code for unpacking CAN messages using the
cantoolsmodule.
The output of this generator is the /out folder, the contents of which can be used by other repositories by including this repository as a submodule.
Do not edit the
/outfolder directly. If changes are needed, the generator code must be modified.
Install uv, then:
cd tsgen
uv syncFrom the command line:
uv run tsgen/main.pyAfter a new set of configurations are generated, the corresponding commit to main should be tagged with a new version number:
git tag v1.1.2
git push --tagsOther repos using the generated outputs should be updated to the latest release at the same time to ensure they are using the same definitions.