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. The electrical BOM contains the device we are using for experiments.
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 can0
# For CAN FD at 5mbps (recommended)
openarm-can-configure-socketcan can0 -fd -b 1000000 -d 5000000
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
dmesgfor device logs - Some serial based devices may need wrappers like
slcandto be visible inip link show - Check supported bitrate values and device compatibility
- Load kernel modules like
sudo modprobe slcan
sudo modprobe can
sudo modprobe can_raw