We have alot of customers that want to use their USB based PCAN-interfaces on a Raspberry PI, specifically
using Raspbian / Raspberry PI OS.
Our Interfaces can either be used as character devices (CharDev) with our proprietary APIs (Such as PCANBasic, CAN2.0 API, CAN FD API) or as network devices (NetDev) using the SocketCAN API.
This guide will outline the necessary steps for both.
PCAN-APIs (CharDev)
Here a small guide which we have tested on a RPI 4 with the 2019-07-10-raspbian-buster.img:
Download the latest raspbian image and install it on a sd card using Win32DiskImager or any other tool
boot your RPI, and setup all necessary settings (language, network etc.)
now update your PI to the latest version and reboot once:
Code: Select all
$ sudo apt get update
Code: Select all
$ sudo apt get upgrade
Code: Select all
$ reboot
Code: Select all
$ sudo apt-get install raspberrypi-kernel-headers
Code: Select all
$ sudo apt-get install libpopt-dev
Link PCAN-Linux Page:
http://www.peak-system.com/fileadmin/me ... /index.htm
Untar the package:
Code: Select all
$ tar -xzf peak-linux-driver-8.14.0.tar.gz
Code: Select all
$ cd peak-linux-driver-8.14.0
Code: Select all
$ make clean
Code: Select all
$ make PCC=NO PCI=NO ISA=NO DNG=NO
Install Driver:
Code: Select all
$ sudo make install
Code: Select all
$ sudo modprobe pcan
Code: Select all
$ cat /proc/pcan
the usage is explained in details in the PCAN-Linux documentation, chaper 4 -"Usage of the Driver"
Link PCAN-Linux Documentation:
http://www.peak-system.com/fileadmin/me ... an_eng.pdf
SocketCAN (NetDev)
The mainline-kernel drivers for PCAN-Interfaces are included in the latest Raspberry PI OS releases,
we were able to confirm this being the case for the following releases:
Current Raspberry PI OS Releases:
- Raspberry PI OS based on Debian 11 (2022-01-28-raspios-bullseye)
- Raspberry PI OS based on Debain 10 (2022-01-28-raspios-buster) - Legacy
via "ip link", enumerated in ascending order as can0, can1, etc.
For information on how to use the devices, please scroll down to the USAGE ScoketCAN section below:
Older Raspbian / Raspberry PI OS Releases:
Older version of Raspbian /Raspberry PI OS do not include the mainline-kernel drivers
and need additional steps to use your USB-based PCAN-interfaces with SocketCAN:
Here a small guide which we have tested on a RPI 4 with the 2019-07-10-raspbian-buster.img:
Download the latest raspbian image and install it on a sd card using Win32DiskImager or any other tool
boot your RPI, and setup all necessary settings (language, network etc.)
now update your PI to the latest version and reboot once:
Code: Select all
$ sudo apt get update
Code: Select all
$ sudo apt get upgrade
Code: Select all
$ reboot
Code: Select all
$ sudo apt-get install raspberrypi-kernel-headers
Code: Select all
$ sudo apt-get install libpopt-dev
Link PCAN-Linux Page:
http://www.peak-system.com/fileadmin/me ... /index.htm
Untar the package:
Code: Select all
$ tar -xzf peak-linux-driver-8.14.0.tar.gz
Code: Select all
$ cd peak-linux-driver-8.14.0
Code: Select all
$ make clean
Code: Select all
$ make PCC=NO PCI=NO ISA=NO DNG=NO NET=NETDEV_SUPPORT
Install the driver:
Code: Select all
$ sudo make install
Code: Select all
$ sudo modprobe pcan
Code: Select all
$ cat /proc/pcan
You can now proceed with using the devices with SocketCAN as described below:
USAGE SocketCAN
Using "ip link" the devices will be listed as can0, can1 in ascending order:
Code: Select all
pi@raspberrypi:~ $ ip link ls
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DORMANT group default qlen 1000
link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
4: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
link/can
In case you want to install the can-utils:
Code: Select all
pi@raspberrypi:~ sudo apt-get install can-utils
Code: Select all
pi@raspberrypi:~ $ sudo ip link set can0 up type can bitrate 500000
Code: Select all
pi@raspberrypi:~ $ candump can0
can0 100 [8] 50 43 41 4E 2D 55 53 42
can0 101 [8] 75 73 65 64 20 6F 6E 20
can0 102 [8] 52 61 73 70 69 6F 73 21
We hope this guide will help you getting started with using your PCAN-USB inteface
on Raspberry PI.
Best Regards
Marvin