Auto-configure CAN Interface on Ubuntu

Overview

To avoid bringing up the can interface every time we reboot or plug in the cable, we can use the following setting to automate the process.

Normally, we will need this command to bring up the interface and set the bitrate.

sudo ip link set can0 up type can bitrate 1000000

Now we want to set a configuration file once and be able to use the interface when the cable is plugged in.

Steps

Add a new file: /etc/systemd/network/99-interbotix.network.

Put in the following lines.

[Match]
Name=can0

[CAN]
BitRate=1000000

Reboot the machine.

Result

Now can0 should be up when we plug in the cable. And we’ll get no such device error when it’s unplugged.

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据