내 스크립트를 사용하여 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