Skip to main content
Version: 2.0

Step 2: Setup SocketCAN Interface

Configure your CAN interface to communicate with the OpenArm motors. This step sets up SocketCAN on Linux to enable CAN bus communication.

Prerequisites​

Before proceeding, ensure you have the required tools installed:

sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:openarm/main
sudo apt update
sudo apt install -y \
can-utils \
iproute2 \
libopenarm-can-dev \
openarm-can-utils

Find Your CAN Interface​

First, identify your CAN interface device. List network interfaces to find your CAN adapter and look for interfaces like can0, can1, slcan0, etc.

ip link show

Setup the interface​

Replace can0 with your actual CAN interface name and use a baudrate supported by you interfaces for the steps.

Option 1: use OpenArm CAN library​

The OpenArm CAN library includes convenient setup commands, example usage:

# For CAN 2.0
openarm-can-configure-socketcan-4-arms

# For CAN FD at 5mbps (recommended)
openarm-can-configure-socketcan-4-arms -fd -b 1000000 -d 5000000

Alternatively, use openarm-can-cli to configure individual interfaces. For detailed usage, see CAN CLI Reference.

# CAN FD at 5Mbps (recommended)
openarm-can-cli -i can0 can_configure

# CAN 2.0
openarm-can-cli -i can0 can_configure --no-fd

Option 2: setup manually​

CAN 2.0 Mode

sudo ip link set can0 down
# configure CAN 2.0 with 1mbps
sudo ip link set can0 type can bitrate 1000000
sudo ip link set can0 up

CAN FD Mode

ip link set can0 down
# configure CAN FD with 5mbps
sudo ip link set can0 type can bitrate 1000000 dbitrate 5000000 fd on
sudo ip link set can0 up

Verify Configuration​

Check that your CAN interface is properly configured:

# Verify interface is up and running
ip link show can0

# Monitor CAN traffic (optional)
candump can0

# Test monitoring
cansend can0 ...

Troubleshooting​

If the interface configuration fails:

  • Verify physical connections
  • Verify driver installation for your specific CAN adapter
  • Check dmesg for device logs
  • Some serial based devices may need wrappers like slcand to be visible in ip link show
  • Check supported bitrate values and device compatibility
  • Load kernel modules like
    sudo modprobe slcan
    sudo modprobe can
    sudo modprobe can_raw