Connecting to a CAN bus via a remote computer

Suppose we have two PCs on the same network (which could be a VPN). There is a SLCAN adapter connected to PC A; we are sitting in front of PC B and want to interact with the CAN bus to which PC A is connected. Both PCs run GNU/Linux.

Install can-utils on both PCs (APT/AUR package can-utils). Grab cannelloni, build & install it on both PCs following the instructions in the README:

Don’t forget to do sudo ldconfig after installation (or sudo ldconfig /usr/local/lib or whatever if the installation destination is not configured as a default ldconfig path). Then grab setup_slcan -- a simple script for managing SocketCAN SLCAN interfaces on GNU/Linux · GitHub and put it in your PATH.

On PC A

Initialize slcan0:

sudo setup_slcan -r /dev/serial/by-id/usb-Zubax_Robotics_Zubax_Babel_32003D000757424E3430302000000000-if00

Run the bridge:

cannelloni -I slcan0 -R 192.168.1.200

On PC B

Set up vcan0:

sudo modprobe can
sudo modprobe can_raw
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set vcan0 mtu 72  # Optional: Enable CAN FD by configuring MTU=64+8
sudo ip link set up vcan0

Run the bridge:

cannelloni -I vcan0 -R 192.168.1.6

Test

Ensure there is something connected to PC A’s CAN bus. Ensure you have Yakut installed & configured. Then you can interact with it from PC B as if it was connected to vcan0:

source env_vcan0.sh  # Whatever your configuration is
y mon -P ~/allocation_table.db
2 Likes

If you want to remotely upload new software, simply say:

y file-server /path/to/firmware/dir/ --update-software

You can also say this to force an update regardless of the version check:

y file-server /path/to/firmware/dir/ --update-software=125  # 125 is the node-ID here

The process will take some time, though, because cannelloni introduces a significant latency, and all request-response interactions (like the firmware download) are affected.