我想在启动时设置虚拟SocketCAN接口。以下几行做我想要的(手动):
ip link add dev vcan0 type vcan
ip link set up vcan0
(要么)
ip link add dev vcan0 up type vcan
我有一种提出方法 物理 热插拔时的USB CAN接口 - 我添加以下行 /etc/network/interfaces
:
allow-hotplug can0
iface can0 can static
bitrate 250000
up /sbin/ip link set $IFACE down
up /sbin/ip link set $IFACE up type can
我现在想提出来 vcan
启动界面也是如此。所以我自动添加了 vcan
模块并将这些行添加到 /etc/network/interfaces
:
auto vcan0
iface vcan0 can static
bitrate 0 # NEEDED but not supported
pre-up /sbin/ip link add dev $IFACE type vcan
up /sbin/ip link set $IFACE up
但奇怪的是这种方法不起作用:开机或运行时 ifup vcan0
我得到了以下错误:
Configuring interface vcan0=vcan0 (can)
/sbin/ip link add dev $IFACE type vcan
...
ip link set vcan0 type can bitrate 0
RTNETLINK answers: Operation not supported
Failed to bring up vcan0.
..当我添加线 bitrate <somevalue>
或者我明白了
Configuring interface vcan0=vcan0 (can)
Missing required variable: bitrate
Missing required configuration variables for interface vcan0/can.
Failed to bring up vcan0.
..当我省略比特率设置时。
所以它看起来像我 不得不 组 bitrate
和 一定不 设置它 - 同时。
我在这做错了什么?
附:当然我可以简单地运行 ip link add ..
在启动时,但我想对两个接口使用相同的方法。