私のスクリプトを使ってUSB-UARTブリッジを列挙したいと思います。スクリプトは特定の属性を使用して呼び出され、新しいdevfsノード名を返す必要があります。
コンソールでスクリプトをテストしました。
./rc3e.py -d get-devfs-node tty --vendor 10C4 --product EA60 --driver cp210x --serial "Board=KC705;Serial=5081a76781f40229d39e6c9802400fd2" KC705_0/ttyUSB
静的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"
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