# SocketCAN problem

**URL:** <https://forum.zubax.com/t/socketcan-problem/1955>\
**Category:** Cyphal & DroneCAN\
**Created:** [June 16, 2022, 2:34pm UTC](https://forum.zubax.com/t/socketcan-problem/1955 "2022-06-16T14:34:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JChMATHAE](https://forum.zubax.com/user_avatar/forum.zubax.com/jchmathae/32/883_2.png) [@JChMATHAE](https://forum.zubax.com/u/JChMATHAE)\
**Post date:** [June 16, 2022, 2:34pm UTC](https://forum.zubax.com/t/socketcan-problem/1955/1 "2022-06-16T14:34:05Z")

</div>

Hello,

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?

Thanks!

---

<div class="post-metadata">

**Author:** ![pavel-kirienko](https://forum.zubax.com/user_avatar/forum.zubax.com/pavel-kirienko/32/180_2.png) [@pavel-kirienko](https://forum.zubax.com/u/pavel-kirienko)\
**Post date:** [June 16, 2022, 3:17pm UTC](https://forum.zubax.com/t/socketcan-problem/1955/2 "2022-06-16T15:17:12Z")

</div>

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:

> <https://gist.github.com/pavel-kirienko/32e395683e8b7f49e71413aebf5e1a89>

Not directly related but new applications should be using [OpenCyphal](https://opencyphal.org).

---

<div class="post-metadata">

**Author:** ![JChMATHAE](https://forum.zubax.com/user_avatar/forum.zubax.com/jchmathae/32/883_2.png) [@JChMATHAE](https://forum.zubax.com/u/JChMATHAE)\
**Post date:** [June 16, 2022, 3:51pm UTC](https://forum.zubax.com/t/socketcan-problem/1955/3 "2022-06-16T15:51:04Z")

</div>

Thank you Pavel! I’ll try this tomorrow.

---

<div class="post-metadata">

**Author:** ![JChMATHAE](https://forum.zubax.com/user_avatar/forum.zubax.com/jchmathae/32/883_2.png) [@JChMATHAE](https://forum.zubax.com/u/JChMATHAE)\
**Post date:** [June 17, 2022, 11:56am UTC](https://forum.zubax.com/t/socketcan-problem/1955/4 "2022-06-17T11:56:52Z")

</div>

It works flawlessly (the exact command is

> sudo ip link set up slcan0

).

Thanks again Pavel!
