Repository tasked with interfacing between the CAN network data and external applications.
Our subsystem's modules generate data about a certain topic, i.e. BMS charge controller status, solar panel deck temperatures etc. This repo defines these topics and defines methods to handle data.
Install Python 3.x and Git Bash for Windows. Then you can use the commonly used Linux commands (ls, cd, etc.) on your Windows machine.
This step is optional. If you want to store car data, setting up an SQL database is very much recommended. Please refer to setup_database.md
for more details.
This step isn't required, yet is highly recommended. It isolates the installation of this project from the global python installation and prevents version mismatches.
pip install virtualenv
Then source the configuration in the active shell. This will allow the programs in the virtualenv to be used without the source directory prepended.
python -m venv .venv
source .venv/bin/activate
source .venv/Scripts/activate
You should now see a (.venv)
string in your CLI prompt, indicating that you are in the virtual environment.
Then you can install the following modules required in this project's scripts with the following command:
pip install -r requirements.txt
Windows users still need to install the following python module for compatibility with linux:
pip install windows-curses
The CAN USB analyzers require some drivers that you can download online.
The PCAN driver can be found here:
The official seedstudio drivers have errors in them, preventing compilation. Install these drivers instead:
For Windows, use the official github repository.
Before running these commands, make sure your local filetree has the necessary message tree description. This can be generated using the following command:
python source_tree.py
For details regarding the scripts, refer to Python CAN docs or read the manpages.
Car data CAN be logged directly into the database or alternatively into a logfile. For more information, please refer
to the file can_logger.md
.
python -m can.player -v -i pcan -b 500000 -c PCAN_USBBUS1 logs/LOGFILE_HERE
Automatically parses values in CAN bus and shows them in CAN viewer.
python -m can.viewer -v -i pcan -b 500000 -c PCAN_USBBUS1 -d type_lookup.txt
Shortcuts:
+---------+-------------------------------+
| Key | Description |
+---------+-------------------------------+
| ESQ/q | Exit the viewer |
| c | Clear the stored frames |
| s | Sort the stored frames |
| h | Toggle highlight byte changes |
| SPACE | Pause the viewer |
| UP/DOWN | Scroll the viewer |
+---------+-------------------------------+
There exists a dashboard application for plotting performance data of the car, such as speed, battery output power etc. The dashboard has a live mode that is intended to monitor the solar racing car while driving. In addition, there's an analyzer application that allows to plot performance data in a given time interval for subsequent analysis.
The dashboard application needs the database to be running.
python dashboard.py
If you want to send your device a certain message over CAN, you can use the pub
utility.
python pub.py -t /stwheel/stwheel_heartbeat -c PCAN_USBBUS1 -b 500000 --data 0 0 0
A decoder program takes logfiles and inserts their data into the database. This is useful for analyzing the data in hindsight. For straight-forward usage, type the following command into the terminal.
python log_decoder.py
However, there are multiple option for the decoder including a live decoder. For more information on the decoder, please
refer to log_decoder.md
.
If you want to delete all entries in the database, just execute the following command
python db_utils.py --refresh