CAN Interface Setup
This guide brings up a SocketCAN interface on a Linux host and verifies communication with Robstride 00 motors.
Prerequisites
- Linux (Ubuntu 20.04+ recommended)
- CAN interface hardware (Canable, PEAK PCAN-USB, or similar)
can-utilspackage
Install can-utils
sudo apt update
sudo apt install can-utilsBring Up the Interface
Plug in your CAN adapter
For USB adapters (Canable), the kernel auto-loads the gs_usb driver. Check it appeared:
ip link show | grep can
# should list: can0Set bus speed and enable the interface
sudo ip link set can0 type can bitrate 1000000
sudo ip link set can0 upFor Raspberry Pi with MCP2515 HAT, add to /boot/config.txt:
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25then run the same ip link commands after reboot.
Verify the interface is up
ip link show can0
# Expected: can0: <NOARP,UP,LOWER_UP,ECHO> ...Sniff the bus with candump
candump can0Send the motor-enable command from another terminal (see Motor Control) and confirm frames appear here.
If candump shows error frame entries, check termination resistors and cable length. Also verify bus speed matches the motor’s configured speed (default 1 Mbit/s).
Persistent Configuration (systemd-networkd)
To bring up the CAN interface automatically at boot, create /etc/systemd/network/80-can.network:
[Match]
Name=can0
[CAN]
BitRate=1000000Then enable networkd:
sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkdPython CAN Library
Install python-can for scripting:
pip install python-canBasic smoke test — listen for one frame:
import can
bus = can.Bus(channel='can0', interface='socketcan')
msg = bus.recv(timeout=5.0)
if msg:
print(f"ID: {msg.arbitration_id:#x} Data: {msg.data.hex()}")
else:
print("No message received")
bus.shutdown()