SocketCAN problem


I am trying to use the Babel module with Ubuntu 20.04.4 LTS in a C++ program.

The module is connected through an USB interface, and via CAN bus to a µC that only sends heartbeat messages.
Using “uavcan_gui_tool” this heartbeat message is displayed and updated.

In my C++ program I am using the socketcan.h/cpp and libcanard libraries.
After launching

sudo slcand -o -s8 -t hw -S 3000000 -F /dev/serial/by-id/usb-Zubax_Robotics_Zubax_Babel_320042000757424E3430302000000000-if00

with the answer

[5] attached TTY /dev/serial/by-id/usb-Zubax_Robotics_Zubax_Babel_320042000757424E3430302000000000-if00 to netdevice slcan0

in the C++ program the socketcanInit (&ifCAN, “slcan0”) returns 0, the ioctl() with SIOCGIFFLAGS returns IFF_RUNNING, but the write() in socketcanTransmit() returns with errno==ENETDOWN

Any hint?


I think you need to bring the iface up, like ip link slcan0 up. Here’s a script that is more convenient than running slcand manually:

Not directly related but new applications should be using OpenCyphal.

Thank you Pavel! I’ll try this tomorrow.

It works flawlessly (the exact command is

sudo ip link set up slcan0


Thanks again Pavel!