using slcand to use socketCAN with chardev interface

This forum covers PCAN-Linux and Linux development issues concerning our products
Locked
0xfafa
Posts: 2
Joined: Fri 18. Feb 2022, 20:37

using slcand to use socketCAN with chardev interface

Post by 0xfafa » Tue 22. Feb 2022, 20:51

Hello,

I have the following USB device: PCAN-USB Pro FD (01h PCB02h) fw v3.2.0 bl v2.1.0 connected to a PI4. The PI4 is running balena's IOT software which contains a YOCTO-based Host OS and our application container. The peak drivers were thus not part of the host OS but I managed to build them by finding appropriate kernel headers, etc. When I build in chardev mode, I see there are /dev/pcanusb32 and /dev/pcanusb33 devices, and using pcanfdtst I can read FD frames. However, for compatibility with the rest of our software stack I would like to use the socketCAN interface. For other USB devices I would use the slcand utility to map the serial device to a virtual can network-based device which then shows up as can0 in ip link. However, when I run this I get the following error in dmesg.

Code: Select all

[232628.396224] pcan: __pcan_ioctl(cmd=21505): unsupported cmd (dir=0 type=84 nr=1 size=0)
There is another forum message viewtopic.php?f=59&t=2491&start=10 with same error for a PCI device but I was unable to find a resolution.

My other option is to build the peak driver to use the network interface. However, when I try to load it, it fails because it depends on driver can-dev which is also missing in our build (though can and can-raw are available) and I have not been able to find the source for that.

Can you suggest how to address either the slcand problem or the can-dev issue?

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: using slcand to use socketCAN with chardev interface

Post by M.Heidemann » Wed 23. Feb 2022, 07:57

Hello,

You cannot use SocketCAN with the chardev driver variant, it only supports
PEAKs Linux APIs. You'll need to use the NetDev variant, here's how you do that:

If you want to use SocketCAN, uninstall the current driver (from the peak-driver directory):

Code: Select all

$ sudo make uninstall
Clean up build environment

Code: Select all

make clean
Build driver as NetDev:

Code: Select all

$ sudo make NET=NETDEV_SUPPORT
intall the driver:

Code: Select all

$ sudo make install
Load the driver:

Code: Select all

 $ sudo modprobe pcan 
You PCAN-USB should now show up as a net device, like
can0, can1, can2, etc.

You can now use it with SocketCAN.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

0xfafa
Posts: 2
Joined: Fri 18. Feb 2022, 20:37

Re: using slcand to use socketCAN with chardev interface

Post by 0xfafa » Thu 24. Feb 2022, 00:25

Thank you Marvin,

Using the balenaOS it's a bit more complicated because the drivers are on the host OS and not all are available to the application container but eventually got it working using the NetDev variant.

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: using slcand to use socketCAN with chardev interface

Post by M.Heidemann » Thu 24. Feb 2022, 06:54

Hello,

Glad to hear that you were able to resolve this.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

Locked