CAN Network Configuration and ID Search
Notes Before Use
- Connect the UTOR or a mainboard flashed with CAN bridge firmware to the host via USB.
- Please log in to the host's backend via the network, do not use the serial port.
- If using the FlyOS-FAST system, CAN configuration is not required (the system is pre-configured for 1M rate, 1024 buffer).
Checking if the Host Supports CAN
If using a FLY host, you can skip this step.
Execute the following command to check for kernel CAN support:
sudo modprobe can && echo "Kernel supports CAN" || echo "Kernel does not support CAN"
If "Kernel supports CAN" is displayed, you can proceed with configuration.
Configuring CAN0
⚠️ This operation will overwrite the existing CAN0 configuration. A system restart is required after completion. FAST system does NOT need to execute this!
Choose the configuration method based on your system type:
- Standard Linux System
- Raspberry Pi System
Standard Linux System
1M Rate Configuration:
sudo /bin/sh -c "cat > /etc/network/interfaces.d/can0" << EOF
allow-hotplug can0
iface can0 can static
bitrate 1000000
up ifconfig \$IFACE txqueuelen 1024
pre-up ip link set can0 type can bitrate 1000000
pre-up ip link set can0 txqueuelen 1024
EOF
500K Rate Configuration:
Change 1000000 to 500000 in the command above.
Raspberry Pi System
Create the network configuration file (you can modify the BitRate value):
sudo tee /etc/systemd/network/99-can.network > /dev/null <<'EOF'
[Match]
Name=can*
[CAN]
BitRate=1000000
RestartSec=100ms
EOF
Create the link configuration file (buffer size is not recommended to change):
sudo tee /etc/systemd/network/99-can.link > /dev/null <<'EOF'
[Match]
OriginalName=can*
[Link]
TxQueueLength=1024
EOF
Finally, restart the device:
sudo reboot
Commands for Searching CAN ID
- Search command for standard hosts
~/klippy-env/bin/python ~/klipper/scripts/canbus_query.py can0 - Search command for FLY hosts
python3 ~/klipper/scripts/canbus_query.py can0 - If an ID appears and
Application:at the end showsKlipper, it means this ID can be used directly. - If an ID appears and
Application:at the end showsCANBOOTorKatapult, it means firmware needs to be flashed before it can be used.Loading...
Error Messages
- Common errors are listed below:
- OSError: [Errno 19] No such device
- can.CanError: Failed to transmit: [Errno 100] Network is down
- can.CanError: Failed to transmit: [Errno 105] No buffer space available
- The first one indicates the host cannot find the CAN device (mainboard flashed with USB bridge firmware or UTOC).
- The second one indicates the host has not configured or has misconfigured CAN0.
- The third one indicates insufficient host buffer or system issues causing buffer crash.
- For the second and third points, refer to the "Configuring CAN0" section and reconfigure.
Guide and Troubleshooting for Searching Toolboard ID
1. Check and Configure CAN Rate
The CAN communication rate of the toolboard firmware must exactly match the configuration of the host (mainboard), otherwise the device will not be discoverable.
Steps:
- Run the following command in the host terminal to view the current status of the CAN0 interface:
ip -details link show can0 - In the output, confirm two key parameters:
bitrate: The current CAN communication rate (e.g.,1000000means 1Mbps).TxQueueLength: Transmit queue length / buffer size (e.g.,1024).
The image below shows an example of the command output. Please focus on checking if the bitrate parameter within the red box matches your device settings:
2. Exclude System ID Occupation
If the toolboard is already flashed with Klipper firmware and its ID has been written into the host's configuration file (printer.cfg), this ID will be occupied by the system and will not appear in searches.
Solution:
- Temporarily comment out or delete all configuration sections related to that toolboard in
printer.cfg. - After making the changes, you must completely power off the machine and disconnect power for about 10 seconds, then power it back on.
3. Verify CAN Bus Termination Resistors
- A stable CAN bus network must have
120Ωtermination resistors installed at both physical ends of the bus line. - You must verify, using a multimeter while the system is powered off, that the resistance between CAN-H and CAN-L is around
60Ω.
Checking method:
- Operate only when the entire machine is powered off.
- Use the multimeter's resistance mode to measure the resistance between the CAN-H and CAN-L pins on the mainboard's CAN interface or on the toolboard.
- The correct bus resistance should be approximately 60Ω (the result of two
120Ωresistors in parallel). If the measured value deviates significantly (e.g., open circuit or only120Ω), it indicates incorrect wiring or termination resistor configuration.
Configuration rules for each device:
| Device Type | Termination Resistor Requirement | Instructions |
|---|---|---|
| CAN Toolboard | Requires 120Ω termination resistor | Enable via the onboard jumper or DIP switch. |
| Mainboard CAN Interface | Requires 120Ω termination resistor | Enable via the onboard jumper or DIP switch. |
| UTOC-type Converter Module | Has built-in 120Ω resistor | No need to enable other termination resistors. |