Can-Analyzer is a sophisticated CAN bus analyzer developed in C. It provides real-time CAN data capture, filtering, decoding, and more. This tool is designed to help analyze and visualize CAN communication efficiently.
- Basic CAN Communication
- CAN Message Filtering
- CAN Message Decoding
- Real-time Data Display
- Error Detection and Handling
- Statistical Analysis Tools
- Graphical Representation of Data
- Linux-based operating system
- SocketCAN library (for CAN communication)
- Required development tools (gcc, make, build essential)
- Clone the repository:
git clone https://github.com/yezzfusl/CAN-Analyzer.git
- Navigate to the project directory:
cd CAN-Analyzer
- Build the project using
Makefile
:make
To use the CAN Analyzer, run:
./can_analyzer <CAN interface>
Replace <CAN interface>
with the name of your CAN interface (e.g., can0).
Example:
./can_analyzer can0
The program provides the following outputs:
- Real-time display of CAN messages in the terminal
- Statistical analysis of CAN traffic, updated every second
- A PNG file named
can_data.png
with a time-series graph of CAN message values, updated every second
src/
: Contains all source filesinclude/
: Contains header filesMakefile
: Build script for the projectREADME.md
: This file, containing project documentation
can_interface
: Handles CAN socket initialization and communicationcan_filter
: Implements CAN message filteringcan_decode
: Decodes CAN messages into human-readable formatreal_time_display
: Manages the real-time display of CAN messagesstatistical_analysis
: Performs statistical analysis on CAN trafficgraphical_display
: Generates graphical representations of CAN dataerror_handling
: Handles errors and exceptions
- To modify the CAN message filter, edit the
filter
structure inmain.c
- To change the graphing interval, modify the time comparison in the main loop of
main.c
- To add new decoding rules, edit the
decode_can_message
function incan_decode.c
The project has been tested with various CAN devices and simulators. To conduct your own tests:
-
Set up a virtual CAN interface:
- sudo modprobe vcan
- sudo ip link add dev vcan0 type vcan
- sudo ip link set up vcan0
-
Use
cansend
to send test messages:./can_analyzer vcan0
- The current implementation supports Standard CAN (11-bit identifiers) only
- The graphical display is limited to the first byte of each CAN message
- Add support for Extended CAN (29-bit identifiers)
- Implement more sophisticated decoding rules
- Create a GUI for easier interaction and data visualization
Contributions to this project are welcome. Please follow these steps:
- Fork the repository
- Create a new branch for your feature
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.