PCAN USB FD

Install PCAN Linux

Download the Linux Driver from the offical Website:

http://www.peak-system.com/fileadmin/media/linux/index.htm

Driver Download Version 8.5.1 (27.10.2017)

According to the Manual(PDF)

Build Binaries

  1. Untar the compressed tarball file from your $ HOME directory:
$ tar -xzf peak-linux-driver-X.Y.Z.tar.gz
$ cd peak-linux-driver-X.Y.Z
  1. Clean the world:
$ make clean
  1. To build non-real time binaries with default configuration:
$ make

Problem Shooting

src/pcan-settings.c:53:18: fatal error: popt.h: No such file or directory
compilation terminated.
Makefile:147: recipe for target 'pcan-settings' failed
make[1]: *** [pcan-settings] Error 1

Solution

$ sudo apt-get install libpopt-dev

Install Package

Once binaries are built, do the following to install the package:

1.Be sure to be in the driver package root directory:

cd peak-linux-driver-X.Y.Z

2.Install everything (root privileges are required):

a) On Debian-based systems, users can use the sudo command:

$ sudo make install

Usage of the Driver

Load Driver

$ sudo modprobe pcan

Here are the messages it logs when it just has been loaded, for example:

ujet-inside@ujetinside-HP-ProBook-440-G3:~/Downloads/peak-linux-driver-8.5.1$ dmesg | grep pcan
[ 6557.851330] pcan: Release_20171027_n (le)
[ 6557.851331] pcan: driver config [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] 
[ 6557.851382] usbcore: registered new interface driver pcan
[ 6557.851395] pcan: major 243.
ujet-inside@ujetinside-HP-ProBook-440-G3:~/Downloads/peak-linux-driver-8.5.1$ dmesg | grep pcan
[ 6557.851330] pcan: Release_20171027_n (le)
[ 6557.851331] pcan: driver config [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] 
[ 6557.851382] usbcore: registered new interface driver pcan
[ 6557.851395] pcan: major 243.
[ 6684.490863] pcan: PCAN-USB FD (01h PCB01h) fw v2.3.1 bl v2.0.0
[ 6684.491029] pcan: PCAN-USB FD channel 1 device number=0
[ 6684.491153] pcan: usb device minor 32 found
ujet-inside@ujetinside-HP-ProBook-440-G3:~/Downloads/peak-linux-driver-8.5.1$ ls -l /dev/pcan*
lrwxrwxrwx 1 root root      11 Dez 19 16:58 /dev/pcan32 -> pcanusbfd32
crw-rw-rw- 1 root root 243, 32 Dez 19 16:58 /dev/pcanusbfd32

/dev/pcan-usb_fd:
total 0
drwxr-xr-x 2 root root 60 Dez 19 16:58 0
ujet-inside@ujetinside-HP-ProBook-440-G3:~/Downloads/peak-linux-driver-8.5.1$ tree /dev/pcan-usb_fd
/dev/pcan-usb_fd
└── 0
    └── can0 -> ../../pcanusbfd32

1 directory, 1 file

Note: With a properly configured and running Udev system, all of these devices files and directories are generated on the fly. If the target non-RT system does not have a running Udev system, you must create the device files manually each time after driver installation. The driver package provides the shell script driver/pcan_make_devices for this. For example, to create a maximum of 2 devices of each type:

$ cd driver
$ sudo ./pcan_make_devices 2

/proc Interface

One of the first tests to do is to check whether the driver module is correctly loaded and runs as expected. To so, read the /proc/pcan

pseudo file.

Example:

ujet-inside@ujetinside-HP-ProBook-440-G3:~/Downloads/peak-linux-driver-8.5.1$ cat /proc/pcan

*------------- PEAK-System CAN interfaces (www.peak-system.com) -------------
*------------- Release_20171027_n (8.5.1) Dec 19 2017 16:33:21 --------------
*------------- [mod] [isa] [pci] [pec] [dng] [par] [usb] [pcc] --------------
*--------------------- 1 interfaces @ major 243 found -----------------------
*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
32  usbfd   -NA-        0 000 0x001c 00000000 00000000 00000000 00000000 0x0000

/sysfs Interface

For historical reasons, v8.x of the driver always handles the /proc/pcan file, but it should be considered as deprecated and for CAN 2.0 usage only. Since v8.x, the driver also exports all of the /proc/pcan properties (and some more) to the /sysfs interface.

a) The /sys/class/pcan/version attribute exports the driver version number:

ujet-inside@ujetinside-HP-ProBook-440-G3:~$ cat /sys/class/pcan/version
8.5.1

b) The /sys/class/pcan directory exports the list of all the CAN interfaces it handles:

ujet-inside@ujetinside-HP-ProBook-440-G3:~$ tree -a /sys/class/pcan
/sys/class/pcan
├── pcanusbfd32 -> ../../devices/virtual/pcan/pcanusbfd32
└── version

1 directory, 1 file

These entries have been extended to export some PCAN devices private properties, as shown (bold) in the example below (bold-green lines properties are the same as the columns of /proc/pcan):

ujet-inside@ujetinside-HP-ProBook-440-G3:~$ ls -l /sys/class/pcan/pcanusbfd32/
total 0
-r--r--r-- 1 root root 4096 Dez 20 11:36 adapter_name
-r--r--r-- 1 root root 4096 Dez 20 11:32 adapter_number
-r--r--r-- 1 root root 4096 Dez 20 11:36 adapter_version
-r--r--r-- 1 root root 4096 Dez 20 11:36 base
-r--r--r-- 1 root root 4096 Dez 20 11:36 btr0btr1
-r--r--r-- 1 root root 4096 Dez 20 11:36 bus_load
-r--r--r-- 1 root root 4096 Dez 20 11:36 bus_state
-r--r--r-- 1 root root 4096 Dez 20 11:36 clock
-r--r--r-- 1 root root 4096 Dez 20 11:32 ctrlr_number
-r--r--r-- 1 root root 4096 Dez 20 11:36 data_bitrate
-r--r--r-- 1 root root 4096 Dez 20 11:36 data_brp
-r--r--r-- 1 root root 4096 Dez 20 11:36 data_sample_point
-r--r--r-- 1 root root 4096 Dez 20 11:36 data_sjw
-r--r--r-- 1 root root 4096 Dez 20 11:36 data_tq
-r--r--r-- 1 root root 4096 Dez 20 11:36 data_tseg1
-r--r--r-- 1 root root 4096 Dez 20 11:36 data_tseg2
-r--r--r-- 1 root root 4096 Dez 20 11:36 dev
-rw-r--r-- 1 root root 4096 Dez 20 11:32 devid
-r--r--r-- 1 root root 4096 Dez 20 11:36 errors
-r--r--r-- 1 root root 4096 Dez 20 11:32 hwtype
-r--r--r-- 1 root root 4096 Dez 20 11:36 init_flags
-r--r--r-- 1 root root 4096 Dez 20 11:36 irq
-r--r--r-- 1 root root 4096 Dez 20 11:36 irqs
-r--r--r-- 1 root root 4096 Dez 20 11:36 minor
-r--r--r-- 1 root root 4096 Dez 20 11:36 nom_bitrate
-r--r--r-- 1 root root 4096 Dez 20 11:36 nom_brp
-r--r--r-- 1 root root 4096 Dez 20 11:36 nom_sample_point
-r--r--r-- 1 root root 4096 Dez 20 11:36 nom_sjw
-r--r--r-- 1 root root 4096 Dez 20 11:36 nom_tq
-r--r--r-- 1 root root 4096 Dez 20 11:36 nom_tseg1
-r--r--r-- 1 root root 4096 Dez 20 11:36 nom_tseg2
drwxr-xr-x 2 root root    0 Dez 20 11:36 power
-r--r--r-- 1 root root 4096 Dez 20 11:36 read
-r--r--r-- 1 root root 4096 Dez 20 11:36 rx_error_counter
-r--r--r-- 1 root root 4096 Dez 20 11:36 rx_fifo_ratio
-r--r--r-- 1 root root 4096 Dez 20 11:36 status
lrwxrwxrwx 1 root root    0 Dez 20 11:36 subsystem -> ../../../../class/pcan
-r--r--r-- 1 root root 4096 Dez 20 11:36 tx_error_counter
-r--r--r-- 1 root root 4096 Dez 20 11:36 tx_fifo_ratio
-r--r--r-- 1 root root 4096 Dez 20 11:36 type
-rw-r--r-- 1 root root 4096 Dez 20 11:32 uevent
-r--r--r-- 1 root root 4096 Dez 20 11:36 write

Reading the content of all of the above files will display something like that:

$ for f in /sys/class/pcan/pcanusbfd32/*; do [ -f $f ] && echo -n "`basename $f` = " && cat $f; done
adapter_name = PCAN-USB FD
adapter_number = 0
adapter_version = 2.3.1
base = 0x0
btr0btr1 = 0x001c
bus_load = 0.00
bus_state = 0
clock = 80000000
ctrlr_number = 0
data_bitrate = 2000000
data_brp = 1
data_sample_point = 7500
data_sjw = 1
data_tq = 12
data_tseg1 = 29
data_tseg2 = 10
dev = 243:32
devid = 0
errors = 0
hwtype = 18
init_flags = 0x00000004
irq = 0
irqs = 0
minor = 32
nom_bitrate = 500000
nom_brp = 1
nom_sample_point = 8750
nom_sjw = 1
nom_tq = 12
nom_tseg1 = 139
nom_tseg2 = 20
read = 0
rx_error_counter = 0
rx_fifo_ratio = 0.00
status = 0x0000
tx_error_counter = 0
tx_fifo_ratio = 0.00
type = usbfd
uevent = MAJOR=243
MINOR=32
DEVNAME=pcanusbfd32
write = 0

lspcan Tool

The lspcan tool is a shell script based on the /sysfs interface that can be used to get an overview of the PC CAN interfaces and CAN channels of the host.

ujet-inside@ujetinside-HP-ProBook-440-G3:~$ lspcan --help
lspcan: list PEAK-System CAN/CANFD devices found by pcan driver

Option:
-a | --all        equivalent to: -i -s
-f | --forever    forever loop on devices (^C to stop)
-h | --help       display this help
-i | --info       information about pcan devices
-s | --stats      statistics about pcan devices
-t | --title      display a title line over columns
-T | --tree       tree version
-v | --version    display pcan version

The "-i" option displays static properties of devices nodes:

ujet-inside@ujetinside-HP-ProBook-440-G3:~$ lspcan -T -t -i
dev name    port    irq    clock    btrs    bus
[PCAN-USB FD 0]
 |_ pcanusbfd32    CAN1    -    80MHz    500k+2M    CLOSED

On the other hand, running lspcan with –T –t –s –f refreshes the screen every second with a detailed view of statistics collected from all the PC CAN interfaces present on the Linux host:

dev name    port    bus    %bus    rx    %fifo    tx    %fifo    err
[PCAN-USB FD 0]
 |_ pcanusbfd32    CAN1    CLOSED    0.00    0    0.00    0    0.00    0

read/write Interface

results for ""

    No results matching ""