This CAN DBC parser reads and interprets CAN database (DBC) files, which contain information on how to decode raw CAN bus data into understandable signals and messages.
This repository is a fork of the CAN DBC parser used in the Indy Autonomous Challenge (IAC). The original repository contains an integration of this parser into a ros2 node which allows to publish received CAN messages as ros2 topics.
All necessary steps are described in detail here. The instructions below will guide you through all the necessary steps to bring up a CAN interface.
For quick setup, you can run one of the scripts provided in the scripts folder, e.g.
bash scripts/launch_can_interface.sh 4 250000This will bring up 4 can interfaces with a bitrate of 250000 each (currently, only identical bitrates are supported).
Step-by-step instructions:
-
Print all available ip interfaces and see if some CAN interfaces are available. A CAN interface, for example
can0, should show up.ip link show
-
Before enabling the SocketCAN interface, we need to configure it. Run the command below after adjusting the bitrate to your interface.
ip link set can0 type can bitrate 250000
-
Enabling a specific SocketCAN interface is also called “bringing the interface up”:
ip link set up can0 -
Test the can interface with the command below. If the CAN socket is not available, this message will throw an error.
ip addr ls dev can0
-
Finally, received CAN messages can be tested with
can-utils:sudo apt install can-utils
candump can0
- Linux SocketCAN docs: https://www.kernel.org/doc/html/latest/networking/can.html
- Commands to test the SocketCAN interface: https://blog.mbedded.ninja/programming/operating-systems/linux/how-to-use-socketcan-with-the-command-line-in-linux/
- ros2 can_msgs definition: https://index.ros.org/p/can_msgs/#humble
- ros2 SocketCAN interface: https://index.ros.org/p/ros2_socketcan/