这是我的 81-arduino.rules 文件:
KERNEL=="ttyACM*", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0043", ATTRS{serial}=="754393133373519132C0", RUN+="/home/z37/screenrun.sh"
因此,当我插入 Arduino 脚本时应该启动,但什么也没有发生。
$ sudo unbuffer udevadm monitor --environment
custom logging function 0x7f5296f7e250 registered
selinux=0
runtime dir '/run/udev'
calling: monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[16618.840108] add /devices/pci0000:00/0000:00:12.0/usb3/3-1 (usb)
ACTION=add
BUSNUM=003
DEVNAME=bus/usb/003/007
DEVNUM=007
DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1
DEVTYPE=usb_device
MAJOR=189
MINOR=262
PRODUCT=2341/43/1
SEQNUM=2737
SUBSYSTEM=usb
TYPE=2/0/0
UDEV_LOG=6
KERNEL[16618.844515] add /devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0
DEVTYPE=usb_interface
INTERFACE=2/2/1
MODALIAS=usb:v2341p0043d0001dc02dsc00dp00ic02isc02ip01in00
PRODUCT=2341/43/1
SEQNUM=2738
SUBSYSTEM=usb
TYPE=2/0/0
UDEV_LOG=6
KERNEL[16618.848853] add /devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/tty/ttyACM0 (tty)
ACTION=add
DEVNAME=ttyACM0
DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/tty/ttyACM0
MAJOR=166
MINOR=0
SEQNUM=2739
SUBSYSTEM=tty
UDEV_LOG=6
KERNEL[16618.848971] add /devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.1 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.1
DEVTYPE=usb_interface
DRIVER=cdc_acm
INTERFACE=10/0/0
MODALIAS=usb:v2341p0043d0001dc02dsc00dp00ic0Aisc00ip00in01
PRODUCT=2341/43/1
SEQNUM=2740
SUBSYSTEM=usb
TYPE=2/0/0
UDEV_LOG=6
UDEV [16619.510808] add /devices/pci0000:00/0000:00:12.0/usb3/3-1 (usb)
ACTION=add
BUSNUM=003
DEVNAME=/dev/bus/usb/003/007
DEVNUM=007
DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1
DEVTYPE=usb_device
ID_BUS=usb
ID_MM_DEVICE_IGNORE=1
ID_MODEL=0043
ID_MODEL_ENC=0043
ID_MODEL_ID=0043
ID_REVISION=0001
ID_SERIAL=Arduino__www.arduino.cc__0043_754393133373519132C0
ID_SERIAL_SHORT=754393133373519132C0
ID_USB_INTERFACES=:020201:0a0000:
ID_VENDOR=Arduino__www.arduino.cc_
ID_VENDOR_ENC=Arduino\x20\x28www.arduino.cc\x29
ID_VENDOR_ID=2341
MAJOR=189
MINOR=262
PRODUCT=2341/43/1
SEQNUM=2737
SUBSYSTEM=usb
TYPE=2/0/0
UDEV_LOG=6
USEC_INITIALIZED=16618911419
UDEV [16619.516472] add /devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.1 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.1
DEVTYPE=usb_interface
DRIVER=cdc_acm
INTERFACE=10/0/0
MODALIAS=usb:v2341p0043d0001dc02dsc00dp00ic0Aisc00ip00in01
PRODUCT=2341/43/1
SEQNUM=2740
SUBSYSTEM=usb
TYPE=2/0/0
UDEV_LOG=6
USEC_INITIALIZED=16619516339
UDEV [16619.516920] add /devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0
DEVTYPE=usb_interface
INTERFACE=2/2/1
MODALIAS=usb:v2341p0043d0001dc02dsc00dp00ic02isc02ip01in00
PRODUCT=2341/43/1
SEQNUM=2738
SUBSYSTEM=usb
TYPE=2/0/0
UDEV_LOG=6
USEC_INITIALIZED=16619516552
UDEV [16619.666198] add /devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/tty/ttyACM0 (tty)
ACTION=add
DEVLINKS=/dev/serial/by-id/usb-Arduino__www.arduino.cc__0043_754393133373519132C0-if00 /dev/serial/by-path/pci-0000:00:12.0-usb-0:1:1.0
DEVNAME=/dev/ttyACM0
DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/tty/ttyACM0
ID_BUS=usb
ID_MM_CANDIDATE=1
ID_MODEL=0043
ID_MODEL_ENC=0043
ID_MODEL_ID=0043
ID_PATH=pci-0000:00:12.0-usb-0:1:1.0
ID_PATH_TAG=pci-0000_00_12_0-usb-0_1_1_0
ID_REVISION=0001
ID_SERIAL=Arduino__www.arduino.cc__0043_754393133373519132C0
ID_SERIAL_SHORT=754393133373519132C0
ID_TYPE=generic
ID_USB_DRIVER=cdc_acm
ID_USB_INTERFACES=:020201:0a0000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Arduino__www.arduino.cc_
ID_VENDOR_ENC=Arduino\x20\x28www.arduino.cc\x29
ID_VENDOR_ID=2341
MAJOR=166
MINOR=0
SEQNUM=2739
SUBSYSTEM=tty
UDEV_LOG=6
USEC_INITIALIZED=16619561894
我的脚本:
#!/bin/bash gnome-terminal -x sh -c "sudo screen /dev/ttyACM* 115200; bash"
答案1
需要测试以下几件事:
你的脚本是否在运行,但出现了错误?人们会不小心做出各种环境假设,所以只要确保有什么问题防弹在开始的脚本中,例如:
echo running >> /home/z37/screenrun.log
如果事实证明它正在运行,那么您可以修复它。使用完整路径。切勿使用类似 的替换
~
。脚本将从非常原始的上下文中运行。你的 UDEV 规则正确吗?插入时查看日志:
sudo apt-get install expect-dev sudo unbuffer udevadm monitor --environment
检查您的供应商、产品和序列号。
尝试稍微宽松一些的搜索,忽略 KERNEL 和 SERIAL:
SUBSYSTEM=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0043", RUN+="/home/z37/screenrun.sh