CAN Bus Listener

Updated: July 06, 2019

CAN Listener is a simple Python script that reads the data from the CAN network and writes it to a SQLite database for other applications to use.

This script is a prerequisite for almost all avionics-related applications running on the FDR (Raspberry Pi) board.

You can download the most recent source code from GitHub: https://github.com/ExperimentalAvionics/can_listener

Instructions

Assuming you already have Python installed, open a terminal windows and run the following command to install “can” library.

pip install python-can
pip3 install python-can

Create a folder for the Python script /home/pi/can

Download the script from the GitHub and place it to the folder created earlier

Now we need to configure Raspberry Pi to run this script automatically at startup.

Create a config file:

sudo nano /etc/systemd/system/CAN_Listener.service

Copy-paste the following text into the file

[Unit]
Description=Get CAN_Listener service running at boot

[Service]
ExecStart=/usr/bin/python3 /home/pi/can/can_listener.py
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=CAN_Listener
User=pi
Group=pi

[Install]
WantedBy=multi-user.target

Enable the service:

sudo systemctl enable CAN_Listener.service

Start the service:

sudo systemctl start CAN_Listener.service

Check the status:

systemctl status CAN_Listener.service

Some useful links:

https://python-can.readthedocs.io/en/2.1.0/interfaces/socketcan.html

Python CAN documentation (PDF)