Install the tool along with dependencies (python-can) by running python setup.py install
You still need to configure your CAN interface per the instructions below.
The setup consists of two steps. First we need to get the USB-to-Can device working and secondly configure Python-Can for the device.
-
Install a reasonably modern Linux dist (with a kernel >= 3.4), for example Ubuntu.
-
Plug in the USB-to-Can device (we use PEAK PCAN-USB)
-
Load the CAN module (needs to be done after each reboot):
sudo modprobe can
-
Set up the can device (needs to be done after each reboot).
sudo ip link set can0 up type can bitrate 500000
Note: The bit rate may differ between different CAN buses.
-
can0
will now display as a normal network interface
-
Install pip (package management system for python - often installed by default)
-
Install python-can by running:
pip install python-can
-
Verify that the installation worked by running python from the terminal and load the can module.
$ python Python 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import can >>>
Python-Can uses a configuration file ~/.canrc
to specify a CAN interface.
The contents of this file might e.g. be:
[default]
interface = socketcan
channel = can0
Run the following command:
caringcaribou dump
If packets are received, everything is good to go!
The simplest solution is to use a VM hypervisor (like VMware Player or VirtualBox), install a Linux VM and then follow the Linux guide above.