Simulate and monitor CAN bus error messages using Linux and SocketCAN.
This project provides two powerful tools:
- canerrsim: A CAN error frame simulator for generating custom error conditions.
- canerrdump: A CAN error frame monitor for real-time error analysis.
Whether you're testing CAN controllers, debugging protocol implementations, or learning about CAN error handling, these tools are designed to make your life easier.
-
Generates custom CAN error frames for testing and development purposes
-
Simulates 30+ different CAN error conditions
-
Supports error class, arbitration loss, protocol errors, transceiver faults
-
Customizable error counters and data payload
-
Real-time error frame generation
-
Now part of can-utils
- Displays detailed error frame information from CAN interfaces
- Flexible error filtering options
- Human-readable error descriptions
- Real-time error monitoring
- Protocol violation location decoding
- Linux kernel with SocketCAN support (in general any newer then 2009)
- Ubuntu/Debian development tools:
sudo apt-get install build-essential
- Optional: If you do not have real CAN adapter then Virtual CAN adapter vcan0 can be set up like this:
sudo modprobe vcan sudo ip link add dev vcan0 type vcan sudo ip link set vcan0 mtu 72 # needed for CAN FD sudo ip link set vcan0 up
# Download
git clone https://github.com/zeljkoavramovic/canerrsim.git
cd canerrsim
# Build both tools
gcc canerrsim.c -o canerrsim
gcc canerrdump.c -o canerrdump
# Set execute permissions
chmod +x canerrsim canerrdump
Start canerrsim or canerrdump without any parameters to see documentation for their usage.
# Simulate bus-off with arbitration loss on vcan0
./canerrsim vcan0 BusOff LostArBit=12
# Generate protocol error with custom data
./canerrsim can0 FrameFormat Data3=AA Data5=FF ShowBits
# Complex error scenario
./canerrsim vcan0 TxTimeout NoAck CanHiShortToGND WarningRX
# Monitor all errors on can0
./canerrdump can0
# Filter specific errors on vcan0
./canerrdump vcan0 IgnoreTxTimeout IgnoreCounters
# Show error mask bits on can1
./canerrdump can1 ShowBits
# In terminal 1:
./canerrdump vcan0
# In terminal 2:
./canerrsim vcan0 LostArBit=09 Data4=AA TX BusOff NoAck ShowBits
Dual-licensed under:
Originally, canerrsim and canerrdump were developed in FreePascal as part of my SocketCAN wrappers. However, since I frequently use can-utils and install them on every CAN-enabled Linux system, I wanted to include these tools in the suite as well. To achieve this, I rewrote both tools in C and submitted a patch. While only canerrsim was accepted into the official repository, I decided to keep both tools here because canerrdump offers a more human-friendly output compared to candump.
If this project has helped you, support is most welcome:
- ⭐ Star the repository to show your appreciation.
- 💬 Share your feedback or success stories in Discussions.