The SocketCAN utilities provide simple command-line tools for interacting with CAN buses.
candump displays messages on the specified CAN bus. To show all traffic in real time on device can0:
The displayed messages can be filtered using a mask and identifier. Two filter types are available:
[received_can_id] & [can_mask] == [can_id] & [mask]
[received_can_id] & [can_mask] != [can_id] & [mask]
Only show messages with ID 0x123 on vcan0:
Only show messages with ID 0x123 or ID 0x456 on can3:
cansend sends a single CAN frame on the bus using the specified identifier and data bytes. For example:
cansend can0 123#1122334455667788
This sends a message on interface
can0 with identifier
0x123 and data bytes
[0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88]. This tool assumes all values (ID and data) are provided in hexadecimal.
cangen can generate random CAN data, which can be useful for testing. Run
cangen for detailed usage information.
cansniffer displays frames that are currently on the bus, but filters out frames with data that is not changing. This is very useful for reverse engineering CAN bus systems. Run
cansniffer for detailed usage information.