0

Python and RPi n00b here. Trying to get CANopen working on my RPI, and think I'm 8/10s of the way to communicating.

Target device is an RPi 3+ with fairly pedestrian install of Raspbian Buster and 5.4.51-v7+ linux kernel, attached to Kvaser Leaf USB CANopen adapter. CANopen adapter hardware is known to be good, works well with Windows software.

Relevant info: -Installed can-utils -Installed python-can 4.0.0
-Appear to have installed Kvaser drivers successfully (finally got make to complete without errors) -vcan appears to work fine - have successfully transmitted and received test packets with this handy virtual can adapter using can-utils

I can set up the can socket initially:

sudo modprobe can

but when I try to initialize actual hardware, it fails and gets the following error:

sudo ip link add dev can0 type can
RTNETLINK answers:Operation not supported

Obviously I'm missing something, but cannot figure out what. I notice that others have had similar issues (though different hardware). Please advise of solutions and TIA.

mumeh
  • 1
  • And what makes you think it is related to software and not one of the usual CAN hardware beginner mistakes? See [What are the most common causes of CAN bus communication errors?](https://electrical.codidact.com/questions/276251). – Lundin Sep 08 '20 at 07:45
  • Great point. I've made sure the CAN bus is connected and terminated correctly with two active nodes and a sniffer (all on short cable lengths), but the bus never even goes active, per the LED on the USB adapter and system's failure to initiate the can0 socket. Trust me when I say that I can't wait to get to the point where I'm troubleshooting hardware issues instead of configuration mistakes! – mumeh Sep 08 '20 at 15:22

2 Answers2

1

You'll need to uninstall CANlib and then reboot for socketcan to work.

Follow this procedure:

Download the linuxcan tarball again if you no longer have it: http://www.kvaser.com/downloads Extract linuxcan: tar -xf linuxcan.tar.gz Inside of the linuxcan directory, run make to build everything which is required before you can uninstall Now uninstall CANlib with sudo make uninstall You should see something like the following:

Uninstalling pciefd
Remove SocketCAN Kvaser PCI driver from blacklist.
Uninstalling pcican2
Remove SocketCAN Kvaser PCI driver from blacklist.
Uninstalling pcican
Remove SocketCAN Kvaser PCI driver from blacklist.
Uninstalling virtualcan
Uninstalling usbcanII
Remove SocketCAN Kvaser USB driver from blacklist.
Uninstalling mhydra
Uninstalling leaf
Remove SocketCAN Kvaser USB driver from blacklist.
Uninstalling common

Now you can reboot and the ip link commands should work.

speloot
  • 36
  • 1
1

You need to uninstall "Kvaser Linux Drivers and SDK" and install "Kvaser SocketCAN device driver".

avra
  • 3,690
  • 19
  • 19