编辑1:

编辑1:

我想用我自己的脚本枚举我的 USB-UART 桥。应使用某些属性调用该脚本并返回新的 devfs 节点名称。

  1. 我在控制台上测试了脚本:

    ./rc3e.py -d get-devfs-node tty --vendor 10C4 --product EA60 --driver cp210x --serial "Board=KC705;Serial=5081a76781f40229d39e6c9802400fd2"
    KC705_0/ttyUSB
    
  2. 我实现了静态 udev 规则:

    # Silicon Labs - CP2103 USB to UART Bridge Controller
    SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{idProduct}=="ea60", ATTRS{idVendor}=="10c4", ATTRS{serial}=="Board=KC705;Serial=5081a76781f40229d39e6c9802400fd2", SYMLINK+="KC705_0/ttyUSB"
    
  3. 我正在测试 udev 规则/usr/bin/logger

    SUBSYSTEM=="tty", SUBSYSTEMS=="usb", PROGRAM="/usr/bin/logger -p user.error 'product=%attr{idProduct} vendor=$attr{idVendor} drivers=$driver serial=$attr{serial}'"
    

    我被困住了。
    报告的行/var/log/syslog是这样的:

    Sep 23 15:12:26 xxxxxx root: product= vendor= drivers=cp210x serial=
    

$driver被替换,但$att{key}始终为空。

这是我的udevadm info -a -n /dev/ttyUSB2输出:

udevadm info -a -n /dev/ttyUSB2

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/ttyUSB2/tty/ttyUSB2':
    KERNEL=="ttyUSB2"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/ttyUSB2':
    KERNELS=="ttyUSB2"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="cp210x"                                      <-- key of interrest
    ATTRS{port_number}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0':
    KERNELS=="1-3:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="cp210x"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{interface}=="CP2103 USB to UART Bridge Controller"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-3':
    KERNELS=="1-3"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="0100"
    ATTRS{bmAttributes}=="80"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{devnum}=="2"
    ATTRS{devpath}=="3"
    ATTRS{idProduct}=="ea60"                               <-- key of interrest
    ATTRS{idVendor}=="10c4"                                <-- key of interrest
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Silicon Labs"
    ATTRS{maxchild}=="0"
    ATTRS{product}=="CP2103 USB to UART Bridge Controller"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{serial}=="Board=KC705;Serial=5081a76781f40229d39e6c9802400fd2"    <-- key of interrest
    ATTRS{speed}=="12"
    ATTRS{urbnum}=="258427"
    ATTRS{version}==" 1.10"

我应该更改什么才能将这些参数传递给我的脚本?

编辑1:

root@fpga-cloud:/dev# udevadm info /dev/ttyUSB2
P: /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/ttyUSB2/tty/ttyUSB2
N: ttyUSB2
S: KC705_0/ttyUSB
S: serial/by-id/usb-Silicon_Labs_CP2103_USB_to_UART_Bridge_Controller_Board=KC705_Serial=5081a76781f40229d39e6c9802400fd2-if00-port0
S: serial/by-path/pci-0000:00:14.0-usb-0:3:1.0-port0
S: ttyUSB.KC705
E: DEVLINKS=/dev/KC705_2/ttyUSB /dev/serial/by-id/usb-Silicon_Labs_CP2103_USB_to_UART_Bridge_Controller_Board=KC705_Serial=5081a76781f40229d39e6c9802400fd2-if00-port0 /dev/KC705_1/ttyUSB /dev/ttyUSB.KC705 /dev/serial/by-path/pci-0000:00:14.0-usb-0:3:1.0-port0
E: DEVNAME=/dev/ttyUSB2
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/ttyUSB2/tty/ttyUSB2
E: ID_BUS=usb
E: ID_MM_CANDIDATE=1
E: ID_MODEL=CP2103_USB_to_UART_Bridge_Controller
E: ID_MODEL_ENC=CP2103\x20USB\x20to\x20UART\x20Bridge\x20Controller
E: ID_MODEL_FROM_DATABASE=CP210x UART Bridge / myAVR mySmartUSB light
E: ID_MODEL_ID=ea60
E: ID_PATH=pci-0000:00:14.0-usb-0:3:1.0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_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_CP2103_USB_to_UART_Bridge_Controller_Board=KC705_Serial=5081a76781f40229d39e6c9802400fd2
E: ID_SERIAL_SHORT=Board=KC705_Serial=5081a76781f40229d39e6c9802400fd2
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=2
E: SUBSYSTEM=tty
E: TAGS=:systemd:
E: USEC_INITIALIZED=7849322

相关内容