20260108voron 2.4上位机CB1换CM4纪录
现象:遇到以下问题 can配置重启后失效
原因: debian 13 配置方式变更以前的方法已经被抛弃
解决办法:
添加CAN网络接口配置(持久化设置):
添加Can配置sudo vim /etc/systemd/network/can0.network
# /etc/systemd/network/can0.network
[Match]
Name=can0
[CAN]
BitRate=1000000
[Link]
TxQLen=128
还需要创建CAN接口的systemd服务:
# /etc/systemd/system/can0.service
[Unit]
Description=Setup CAN interface can0
Before=network.target
Wants=network-pre.target
After=sys-devices-virtual-net-can0.device
BindsTo=sys-devices-virtual-net-can0.device
[Service]
Type=oneshot
RemainAfterExit=yes
# 加载CAN模块(如果需要)
ExecStartPre=-/sbin/modprobe can
ExecStartPre=-/sbin/modprobe can_raw
ExecStartPre=-/sbin/modprobe can_bcm
# 设置CAN接口参数
ExecStart=/sbin/ip link set can0 type can bitrate 1000000 restart-ms 100
ExecStartPost=/bin/sleep 0.1
ExecStartPost=/sbin/ip link set can0 up txqueuelen 128
# 停止时关闭接口
ExecStop=/sbin/ip link set can0 down
# 失败时重试
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
启用服务:
sudo systemctl enable setup-can0.service
sudo systemctl start can0.service
- 上一篇: 2025年11月13日 日记
- 下一篇: 没有了,已经是最新文章