CAN bus under Linux (WIP)
Bensuperpc February 01, 2025 [Software, Hardware] #Features #CAN #bus
Features (Series)
CAN bus under Linux (WIP)
Benchmarking Webp format (WIP)
Tutorial on FFMPEG (WIP)
RTL9210 Firmware and Tools
Comparison of SSDs
Evolutions of CPUs (WIP)
Mesa GPU drivers
Deploy Traefik as a reverse proxy with Kubernetes
C++ Code Coverage with CMake and GCOVR
A guide to SFF PCs (WIP)
CAN bus under Linux (WIP)
Benchmarking Webp format (WIP)
Tutorial on FFMPEG (WIP)
RTL9210 Firmware and Tools
Comparison of SSDs
Evolutions of CPUs (WIP)
Mesa GPU drivers
Deploy Traefik as a reverse proxy with Kubernetes
C++ Code Coverage with CMake and GCOVR
A guide to SFF PCs (WIP)
CAN bus
This page provides a brief overview of the CAN bus protocol and how to use it under Linux.
Install tools for CAN bus and setup
On debian/ubuntu based systems:
sudo apt install can-utils
On arch based systems (AUR package):
yay -S can-utils
From source: can-utils
Setup virtual interfaces
Create a virtual CAN interface:
sudo ip link add can0 type vcan
Enable standard CAN interface:
sudo ip link set up can0
Enable CAN FD interface:
sudo ip link set up can0 mtu 72Setup hardware interfaces
Enable hardware CAN interface:
sudo ip link set up can0
Set standard CAN interface:
sudo ip link set can0 type can bitrate 125000
Set CAN FD interface:
sudo ip link set can0 type can bitrate 125000 dbitrate 5000000 fd onReceiving data
To read received data from a CAN interface:
candump -cexdtA anySending data
To send data to a CAN interface:
cansend can0 217#1234567890ABCDEF
For CAN FD frames:
cansend can0 112##01234567890ABCDEF
Or with extended data:
cansend can0 112##01234567890ABCDEF1234567890ABCDEF
For CAN FD and BRS (Baud Rate Switch):
cansend can0 112##11234567890ABCDEF
You should see the sent frame in the candump output:
(2026-01-31 14:51:04.623452) can0 TX - - 217 [8] 12 34 56 78 90 AB CD EF
(2026-01-31 14:51:12.489300) can0 TX - - 112 [08] 12 34 56 78 90 AB CD EF
(2026-01-31 14:51:19.698954) can0 TX - - 112 [16] 12 34 56 78 90 AB CD EF 12 34 56 78 90 AB CD EF
(2026-01-31 14:51:29.358900) can0 TX B - 112 [08] 12 34 56 78 90 AB CD EFRemove hardware interfaces
To remove the hardware CAN interface:
sudo ip link set down can0