This repository contains a Python-based tool to parse DBC formatted CAN log files and plot the signals. It leverages cantools
for parsing DBC files and matplotlib
for plotting signals, providing an easy way to visualize CAN signal data.
- Parse DBC files to extract signal definitions
- Read and parse CAN log files
- Decode signals from CAN messages
- Plot the decoded signals
All required packages are listed in the requirements.txt
file.
- Python 3.6 or higher
- cantools
- matplotlib
-
Clone the repository:
git clone https://github.com/kiranj26/CAN-Log-Parser.git cd CAN-Log-Parser
-
Install the required dependencies:
pip install -r requirements.txt
-
Place your DBC file and log file in the
data/
directory. -
Run the main script with the appropriate arguments:
python src/main.py PATH_TO_LOG/example.txt PATH_TO_DBC/example.dbc SignalName StartTime EndTime
Example:
```bash
python src/main.py ../data/test_log.txt ../data/test.dbc SAF_SpeedTest 43.2 45.6
```
src/
: Contains the main script and related files.main.py
: Main script to run the tool.
data/
: Directory to place your DBC and log files.requirements.txt
: List of dependencies.
Parses the DBC file located at file_path
.
Parses the log file located at log_file_path
using the parsed DBC data.
Processes a single CAN message and extracts the signals.
Prints the parsed CAN data.
Plots the specified CAN signal within the given time range.
To run the script, navigate to the directory containing main.py
and execute the following commands:
python src/main.py test SAF_SpeedTest
OR
python src/main.py test SAF_SpeedTest 43.2 45.6
These commands will parse the test.dbc and test_log.txt files located in the data/ directory, process the CAN messages, and generate a plot for the SAF_SpeedTest signal.
The GUI built using PyQt5 allows users to interactively select and plot CAN signals from the log file.
- Multiple Plot Options: Select which subplot to plot the signals in, allowing for easy comparison of multiple signals.
- Data Filtering: Filter the data to be plotted by selecting specific start and end times.
- Advanced Plot Customization: Customize the plot's appearance, including zooming, panning, and adjusting plot sizes.
- Data Export and Import: Export the plotted data to CSV or import previously saved data for further analysis.
- Interactive Features: Zoom, pan, and interact with the plot to analyze specific sections of the data.
- Annotations and Markers: Add annotations and markers to the plot for highlighting important events.
- User-Friendly Interface: Easy-to-use interface with buttons for loading files, plotting signals, and clearing plots.
- Enhanced Signal Selection: Select and clear signals with ease, allowing for dynamic plotting.
- Run the GUI application:
python gui/gui_main.py
- Load the DBC and log files using the provided buttons.
- Select the signals you want to plot from the list.
- Click the "Plot Signals" button to visualize the selected signals.
- Use the interactive features to zoom, pan, and analyze the plots.
python gui/gui_main.py
Feel free to contribute by adding new algorithms or improving the existing implementations. Please follow the contribution guidelines outlined in the CONTRIBUTING.md file.
Kiran Jojare
Embedded Software Engineer
Phone: 720-645-6212
Email: [email protected]
This project is licensed under the MIT License. See the LICENSE file for more details.
Happy Coding! 🚀