我有这个适配器,我正在拼命地尝试将它安装在 Ubuntu 中,以便我可以can-utils
用来监视设备,但我失败了。
我正在尝试使用 can-utils 与 14.04 中的 can-bus 适配器的串行通信,这是我正在尝试使用的canopen 设备,这是我正在使用的适配器
dmesg
:
[ 4316.555254] usb 3-3: new full-speed USB device number 8 using xhci_hcd
[ 4316.572534] usb 3-3: New USB device found, idVendor=1a86, idProduct=7523
[ 4316.572541] usb 3-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 4316.572545] usb 3-3: Product: USB2.0-Serial
[ 4316.573058] ch341 3-3:1.0: ch341-uart converter detected
[ 4316.574083] usb 3-3: ch341-uart converter now attached to ttyUSB1 …
Run Code Online (Sandbox Code Playgroud) 在以前版本的 Ubuntu 中,我一直使用这个脚本来自动为 USB 到 CAN 桥接设备打开一个网络接口,只要设备插入:
$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
allow-hotplug can0
iface can0 can static
bitrate 250000
up /sbin/ip link set $IFACE down
up /sbin/ifconfig $IFACE txqueuelen 20000
up /sbin/ip link set $IFACE type can bitrate 250000 restart-ms 10
up /sbin/ip link set $IFACE up
Run Code Online (Sandbox Code Playgroud)
此脚本不再起作用,因为 Ubuntu 17.10 未使用 ifupdown,因此/etc/network/interfaces
不再使用文件。我的问题是,如何使用新的netplan
配置系统重写此脚本?
特别是,对于我上面的脚本的运行至关重要的是allow-hotplug can0
检测can0
接口何时可用的行(在将设备插入 USB 端口后不久)。我可以使用新的配置系统来做到这一点吗?