我有CP2105的板子。它是一个 USB 端口上具有两个 uart 接口的 USB 到串行桥接器。我已经阅读了一些指南和 UDEV 文档,但我一直坚持为它们创建符号链接。我希望他们的名字有序列号。问题是它不起作用,即使有简单的规则。
我的规则,应该做我想要的:
ACTION=="add", SUBSYSTEM=="tty", \
ATTR{idVendor}=="10c4", ATTR{idProduct}=="ea70",
ENV{ID_MODEL}=="CP2105_Dual_USB_to_UART_Bridge_Controller", \
SYMLINK+="CP2105$env{ID_USB_INTERFACE_NUM}-$env{ID_SERIAL_SHORT}"
更简单的尝试,应该在末尾添加两个不同数字的符号链接:
ACTION=="add", SUBSYSTEM=="tty", ATTR{idVendor}=="10c4", ATTR{idProduct}=="ea70", SYMLINK+="CP2105%n"
我也有一个规则,它有效,但做了其他事情(阻止其他驱动程序写入此设备):
SUBSYSTEM=="usb", ATTR{idVendor}=="10c4", ATTR{idProduct}=="ea70", ENV{ID_MM_DEVICE_IGNORE}="1"
我的第一台设备的 udevadm 信息输出:
udevadm info -q all /dev/ttyUSB0
P: /devices/pci0000:00/0000:00:14.0/usb3/3-5/3-5.3/3-5.3:1.0/ttyUSB0/tty/ttyUSB0
N: ttyUSB0
S: serial/by-id/usb-Silicon_Labs_CP2105_Dual_USB_to_UART_Bridge_Controller_0087144E-if00-port0
S: serial/by-path/pci-0000:00:14.0-usb-0:5.3:1.0-port0
E: DEVLINKS=/dev/serial/by-path/pci-0000:00:14.0-usb-0:5.3:1.0-port0 /dev/serial/by-id/usb-Silicon_Labs_CP2105_Dual_USB_to_UART_Bridge_Controller_0087144E-if00-port0
E: DEVNAME=/dev/ttyUSB0
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-5/3-5.3/3-5.3:1.0/ttyUSB0/tty/ttyUSB0
E: ID_BUS=usb
E: ID_MM_CANDIDATE=1
E: ID_MODEL=CP2105_Dual_USB_to_UART_Bridge_Controller
E: ID_MODEL_ENC=CP2105\x20Dual\x20USB\x20to\x20UART\x20Bridge\x20Controller
E: ID_MODEL_FROM_DATABASE=CP210x UART Bridge
E: ID_MODEL_ID=ea70
E: ID_PATH=pci-0000:00:14.0-usb-0:5.3:1.0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_5_3_1_0
E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
E: ID_PCI_INTERFACE_FROM_DATABASE=XHCI
E: ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
E: ID_REVISION=0100
E: ID_SERIAL=Silicon_Labs_CP2105_Dual_USB_to_UART_Bridge_Controller_0087144E
E: ID_SERIAL_SHORT=0087144E
E: ID_TYPE=generic
E: ID_USB_DRIVER=cp210x
E: ID_USB_INTERFACES=:ff0000:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=Silicon_Labs
E: ID_VENDOR_ENC=Silicon\x20Labs
E: ID_VENDOR_FROM_DATABASE=Cygnal Integrated Products, Inc.
E: ID_VENDOR_ID=10c4
E: MAJOR=188
E: MINOR=0
E: SUBSYSTEM=tty
E: TAGS=:systemd:
E: USEC_INITIALIZED=5571337818
第二个:
udevadm info -q all /dev/ttyUSB1
P: /devices/pci0000:00/0000:00:14.0/usb3/3-5/3-5.3/3-5.3:1.1/ttyUSB1/tty/ttyUSB1
N: ttyUSB1
S: serial/by-id/usb-Silicon_Labs_CP2105_Dual_USB_to_UART_Bridge_Controller_0087144E-if01-port0
S: serial/by-path/pci-0000:00:14.0-usb-0:5.3:1.1-port0
E: DEVLINKS=/dev/serial/by-path/pci-0000:00:14.0-usb-0:5.3:1.1-port0 /dev/serial/by-id/usb-Silicon_Labs_CP2105_Dual_USB_to_UART_Bridge_Controller_0087144E-if01-port0
E: DEVNAME=/dev/ttyUSB1
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-5/3-5.3/3-5.3:1.1/ttyUSB1/tty/ttyUSB1
E: ID_BUS=usb
E: ID_MM_CANDIDATE=1
E: ID_MODEL=CP2105_Dual_USB_to_UART_Bridge_Controller
E: ID_MODEL_ENC=CP2105\x20Dual\x20USB\x20to\x20UART\x20Bridge\x20Controller
E: ID_MODEL_FROM_DATABASE=CP210x UART Bridge
E: ID_MODEL_ID=ea70
E: ID_PATH=pci-0000:00:14.0-usb-0:5.3:1.1
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_5_3_1_1
E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
E: ID_PCI_INTERFACE_FROM_DATABASE=XHCI
E: ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
E: ID_REVISION=0100
E: ID_SERIAL=Silicon_Labs_CP2105_Dual_USB_to_UART_Bridge_Controller_0087144E
E: ID_SERIAL_SHORT=0087144E
E: ID_TYPE=generic
E: ID_USB_DRIVER=cp210x
E: ID_USB_INTERFACES=:ff0000:
E: ID_USB_INTERFACE_NUM=01
E: ID_VENDOR=Silicon_Labs
E: ID_VENDOR_ENC=Silicon\x20Labs
E: ID_VENDOR_FROM_DATABASE=Cygnal Integrated Products, Inc.
E: ID_VENDOR_ID=10c4
E: MAJOR=188
E: MINOR=1
E: SUBSYSTEM=tty
E: TAGS=:systemd:
E: USEC_INITIALIZED=5570324399
有人可以帮忙吗?
事实证明,我必须改变两件事。首先,我必须用我的规则从文件名中获取数字(我将它从 52 更改为 70)。其次,我注意到这
ATTR{idVendor}=="10c4", ATTR{idProduct}=="ea70"
不起作用,因为没有可用于检查子系统 tty 的属性。我将其更改为适当的环境变量,并以这条规则结束: