PEAK CAN USB Device not Connectable

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
Torsten Robitzki
Posts: 11
Joined: Mon 23. Nov 2020, 18:09

PEAK CAN USB Device not Connectable

Post by Torsten Robitzki » Tue 16. Aug 2022, 10:15

Hello,
I have a small application that utilizes a PEAK CAN USB adapter to communicate with a Bootloader on a embedded device. The small application works flawless with the very same adapter with the very same cable setup on a MacBook (and I know of customers who used the same application on windows).

Now, I try to port the application to Linux. I run a Ubuntu in VMWare virtual machine:
uname -a
Linux ubuntu 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
The required drivers seem to be preinstalled with the OS, as promised:
$ grep PEAK_ /boot/config-`uname -r`
CONFIG_CAN_PEAK_PCIEFD=m
CONFIG_CAN_PEAK_PCI=m
CONFIG_CAN_PEAK_PCIEC=y
CONFIG_CAN_PEAK_PCMCIA=m
CONFIG_CAN_PEAK_USB=m
And the CAN device seems to be initialized:
$ lsmod | grep ^peak
peak_usb 53248 0
The CAN device is poweres (see attached foto). But, when calling `CAN_Initialize()` in the application, it fails:
Tue Aug 16 00:12:14 2022 - «____________________________________»
Tue Aug 16 00:12:14 2022 - « PCAN-Basic Log »
Tue Aug 16 00:12:14 2022 - « API v4.6.1.32 »
Tue Aug 16 00:12:14 2022 - «____________________________________»
Tue Aug 16 00:12:14 2022 - PCAN Library Logging Enabled.
Tue Aug 16 00:12:14 2022 - EXIT 'CAN_SetValue' - RESULT: 0x00
Tue Aug 16 00:12:14 2022 - ENTRY 'CAN_Initialize'
Tue Aug 16 00:12:14 2022 - PARAMETERS of CAN_Initialize: Channel: 0x51, Btr0Btr1: 28, HwType: 0x00000000, IOPort: 0x00000000, Interrupt: 0x00000000
Tue Aug 16 00:12:14 2022 - EXIT 'CAN_Initialize' - RESULT: 0x1400
Tue Aug 16 00:12:14 2022 - «____________________________________»
Tue Aug 16 00:12:14 2022 - « ############ »
Tue Aug 16 00:12:14 2022 - «____________________________________»
The pcanbasic_dbg.log:
0000013646.756597: Initializing PCAN-Basic API...
0000013646.756648: Refreshing hardware device list...
0000013646.756669: ERROR: failed to scan directory (errno=2) '/sys/class/pcan'
0000013646.756674: Found 0 devices in '/sys/class/pcan'
0000013646.756686: ERROR: failed to open file (errno=2) '/sys/class/pcan/version'.
0000013646.772595: Cleaning up PCAN-Basic API...
Here the result of `cat /proc/pcan`
$ cat /proc/pcan
cat: /proc/pcan: No such file or directory
When I connect the CAN device to the host machine of the VM, VMWare asks me if I want to connect the CAN device to the VM and I agree to it (see attached picture).

What could be the problem here? What further investigations do I have to make? Is Ubunut even supported by PEAK?

best regards,

Torsten
USB Device powered
USB Device powered
tempImageo04ZXL.gif (3.34 MiB) Viewed 7817 times
USB Device Recognized by VMWare
USB Device Recognized by VMWare
Bildschirmfoto 2022-08-15 um 21.20.31.jpeg (91.76 KiB) Viewed 7817 times

Torsten Robitzki
Posts: 11
Joined: Mon 23. Nov 2020, 18:09

Re: PEAK CAN USB Device not Connectable

Post by Torsten Robitzki » Tue 16. Aug 2022, 10:47

Maybe this additional information is helpful:
$ sudo modprobe pcan
modprobe: FATAL: Module pcan not found in directory /lib/modules/5.15.0-46-generic
$ ls /sys/class/pcan
ls: cannot access '/sys/class/pcan': No such file or directory

M.Maidhof
Support
Support
Posts: 1751
Joined: Wed 22. Sep 2010, 14:00

Re: PEAK CAN USB Device not Connectable

Post by M.Maidhof » Tue 16. Aug 2022, 11:53

Hi,

the PCANBasic API can't use the SocketCAN driver of the kernel. You have to install the peak-linux-driver-8.xx in chardev mode. Please see info on our Linux driver website for more details:

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

regards

Michael

Torsten Robitzki
Posts: 11
Joined: Mon 23. Nov 2020, 18:09

Re: PEAK CAN USB Device not Connectable

Post by Torsten Robitzki » Tue 16. Aug 2022, 12:01

Hello Michael,

that are bad news! What are my alternatives, if I want to have a very small tool, using your CAN USB adapter and also using the promised feature, that no additional driver installation is required? Which API do I have to program against? What is the point of the PCANBasic API?

thanks in advance,

Torsten

M.Maidhof
Support
Support
Posts: 1751
Joined: Wed 22. Sep 2010, 14:00

Re: PEAK CAN USB Device not Connectable

Post by M.Maidhof » Tue 16. Aug 2022, 14:23

Hi,

please use the kernel SocketCAN driver, if you don't want to use the peak-linux-driver. Download the can-utils to see how you can program apps for the NetDev interface or have a look here for more details:

https://www.kernel.org/doc/Documentatio ... ng/can.txt

Looks like you didn't read the info we have linked on our Linux website.....

regards

Michael

Torsten Robitzki
Posts: 11
Joined: Mon 23. Nov 2020, 18:09

Re: PEAK CAN USB Device not Connectable

Post by Torsten Robitzki » Tue 16. Aug 2022, 14:37

Looks like you didn't read the info we have linked on our Linux website.....
Well, if you look under Support/Development, you can get the impression that PCAN-Basic API is the way to go. Even if you further visit the drivers/linux page, the first information available is, that there is no need to install any drivers.

Of cause, you are right: If you start developing for your devices by looking for Linux drivers and read the "Driver Package for Proprietary Purposes" chapter carefully, you will find out, that PCAN-Basic API is probably not the best way to go and that you have to better write your application twice.
SocketCAN not even mentioned
SocketCAN not even mentioned
Bildschirmfoto 2022-08-16 um 14.34.43.png (1.16 MiB) Viewed 7789 times

M.Maidhof
Support
Support
Posts: 1751
Joined: Wed 22. Sep 2010, 14:00

Re: PEAK CAN USB Device not Connectable

Post by M.Maidhof » Tue 16. Aug 2022, 14:47

Yes, reading the info will help in that matter

regards

Michael.

Post Reply