我有CP2105的板子。它是一款 USB 转串口桥接器,在一个 USB 端口上有两个 UART 接口。我已经阅读了 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
有人可以帮忙吗?
答案1
事实证明,我必须改变两件事。首先,我必须使用更高的规则从文件名中生成数字(我将其从 52 更改为 70)。其次,我注意到这ATTR{idVendor}=="10c4", ATTR{idProduct}=="ea70"
不起作用,因为没有可用于检查子系统 tty 的属性。我将其更改为适当的环境变量,并以以下规则结束:
SUBSYSTEM=="tty", \
ENV{ID_MODEL}=="CP2105_Dual_USB_to_UART_Bridge_Controller", \
ENV{ID_VENDOR_ID}=="10c4", ENV{ID_MODEL_ID}=="ea70", \
SYMLINK+="ttyCP2105-$env{ID_USB_INTERFACE_NUM}-$env{ID_SERIAL_SHORT}"