2015-11-16 80 views
0

這是問了很多次之前,但我還沒有找到任何可行的解決方案,我的情況。在我的情況下,我有兩個基於FTDI的USB < - >串行轉換器,我無法找到任何可區分的功能,以包含在我打算編寫的udev規則中,以便用持久名稱標識它們。當用於ttyUSB1完成區分兩個類似的USB設備

udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0

looking at device '/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/ttyUSB0': 
    KERNEL=="ttyUSB0" 
    SUBSYSTEM=="usb-serial" 
    DRIVER=="ftdi_sio" 
    ATTR{port_number}=="0" 
    ATTR{latency_timer}=="1" 

    looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0': 
    KERNELS=="3-1:1.0" 
    SUBSYSTEMS=="usb" 
    DRIVERS=="ftdi_sio" 
    ATTRS{bInterfaceClass}=="ff" 
    ATTRS{bInterfaceSubClass}=="ff" 
    ATTRS{bInterfaceProtocol}=="ff" 
    ATTRS{bNumEndpoints}=="02" 
    ATTRS{supports_autosuspend}=="1" 
    ATTRS{bAlternateSetting}==" 0" 
    ATTRS{bInterfaceNumber}=="00" 
    ATTRS{interface}=="USB <-> Serial" 

    looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-1': 
    KERNELS=="3-1" 
    SUBSYSTEMS=="usb" 
    DRIVERS=="usb" 
    ATTRS{bDeviceSubClass}=="00" 
    ATTRS{bDeviceProtocol}=="00" 
    ATTRS{devpath}=="1" 
    ATTRS{idVendor}=="0403" 
    ATTRS{speed}=="12" 
    ATTRS{bNumInterfaces}==" 1" 
    ATTRS{bConfigurationValue}=="1" 
    ATTRS{bMaxPacketSize0}=="8" 
    ATTRS{busnum}=="3" 
    ATTRS{devnum}=="21" 
    ATTRS{configuration}=="" 
    ATTRS{bMaxPower}=="90mA" 
    ATTRS{authorized}=="1" 
    ATTRS{bmAttributes}=="80" 
    ATTRS{bNumConfigurations}=="1" 
    ATTRS{maxchild}=="0" 
    ATTRS{bcdDevice}=="0400" 
    ATTRS{avoid_reset_quirk}=="0" 
    ATTRS{quirks}=="0x0" 
    ATTRS{version}==" 1.10" 
    ATTRS{urbnum}=="11" 
    ATTRS{ltm_capable}=="no" 
    ATTRS{manufacturer}=="FTDI" 
    ATTRS{removable}=="removable" 
    ATTRS{idProduct}=="6001" 
    ATTRS{bDeviceClass}=="00" 
    ATTRS{product}=="USB <-> Serial" 

    looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3': 
    KERNELS=="usb3" 
    SUBSYSTEMS=="usb" 
    DRIVERS=="usb" 
    ATTRS{bDeviceSubClass}=="00" 
    ATTRS{bDeviceProtocol}=="01" 
    ATTRS{devpath}=="0" 
    ATTRS{idVendor}=="1d6b" 
    ATTRS{speed}=="480" 
    ATTRS{bNumInterfaces}==" 1" 
    ATTRS{bConfigurationValue}=="1" 
    ATTRS{bMaxPacketSize0}=="64" 
    ATTRS{authorized_default}=="1" 
    ATTRS{busnum}=="3" 
    ATTRS{devnum}=="1" 
    ATTRS{configuration}=="" 
    ATTRS{bMaxPower}=="0mA" 
    ATTRS{authorized}=="1" 
    ATTRS{bmAttributes}=="e0" 
    ATTRS{bNumConfigurations}=="1" 
    ATTRS{maxchild}=="4" 
    ATTRS{bcdDevice}=="0313" 
    ATTRS{avoid_reset_quirk}=="0" 
    ATTRS{quirks}=="0x0" 
    ATTRS{serial}=="0000:00:14.0" 
    ATTRS{version}==" 2.00" 
    ATTRS{urbnum}=="383" 
    ATTRS{ltm_capable}=="no" 
    ATTRS{manufacturer}=="Linux 3.13.0-32-generic xhci_hcd" 
    ATTRS{removable}=="unknown" 
    ATTRS{idProduct}=="0002" 
    ATTRS{bDeviceClass}=="09" 
    ATTRS{product}=="xHCI Host Controller" 

    looking at parent device '/devices/pci0000:00/0000:00:14.0': 
    KERNELS=="0000:00:14.0" 
    SUBSYSTEMS=="pci" 
    DRIVERS=="xhci_hcd" 
    ATTRS{irq}=="40" 
    ATTRS{subsystem_vendor}=="0x17aa" 
    ATTRS{broken_parity_status}=="0" 
    ATTRS{class}=="0x0c0330" 
    ATTRS{enabled}=="1" 
    ATTRS{consistent_dma_mask_bits}=="64" 
    ATTRS{dma_mask_bits}=="64" 
    ATTRS{local_cpus}=="ff" 
    ATTRS{device}=="0x1e31" 
    ATTRS{msi_bus}=="" 
    ATTRS{local_cpulist}=="0-7" 
    ATTRS{vendor}=="0x8086" 
    ATTRS{subsystem_device}=="0x3977" 
    ATTRS{d3cold_allowed}=="1" 

    looking at parent device '/devices/pci0000:00': 
    KERNELS=="pci0000:00" 
    SUBSYSTEMS=="" 
    DRIVERS=="" 

和相同:的輸出

udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0

looking at device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/ttyUSB1': 
    KERNEL=="ttyUSB1" 
    SUBSYSTEM=="usb-serial" 
    DRIVER=="ftdi_sio" 
    ATTR{port_number}=="0" 
    ATTR{latency_timer}=="1" 

    looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0': 
    KERNELS=="3-2:1.0" 
    SUBSYSTEMS=="usb" 
    DRIVERS=="ftdi_sio" 
    ATTRS{bInterfaceClass}=="ff" 
    ATTRS{bInterfaceSubClass}=="ff" 
    ATTRS{bInterfaceProtocol}=="ff" 
    ATTRS{bNumEndpoints}=="02" 
    ATTRS{supports_autosuspend}=="1" 
    ATTRS{bAlternateSetting}==" 0" 
    ATTRS{bInterfaceNumber}=="00" 
    ATTRS{interface}=="USB <-> Serial" 

    looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-2': 
    KERNELS=="3-2" 
    SUBSYSTEMS=="usb" 
    DRIVERS=="usb" 
    ATTRS{bDeviceSubClass}=="00" 
    ATTRS{bDeviceProtocol}=="00" 
    ATTRS{devpath}=="2" 
    ATTRS{idVendor}=="0403" 
    ATTRS{speed}=="12" 
    ATTRS{bNumInterfaces}==" 1" 
    ATTRS{bConfigurationValue}=="1" 
    ATTRS{bMaxPacketSize0}=="8" 
    ATTRS{busnum}=="3" 
    ATTRS{devnum}=="22" 
    ATTRS{configuration}=="" 
    ATTRS{bMaxPower}=="90mA" 
    ATTRS{authorized}=="1" 
    ATTRS{bmAttributes}=="80" 
    ATTRS{bNumConfigurations}=="1" 
    ATTRS{maxchild}=="0" 
    ATTRS{bcdDevice}=="0400" 
    ATTRS{avoid_reset_quirk}=="0" 
    ATTRS{quirks}=="0x0" 
    ATTRS{version}==" 1.10" 
    ATTRS{urbnum}=="11" 
    ATTRS{ltm_capable}=="no" 
    ATTRS{manufacturer}=="FTDI" 
    ATTRS{removable}=="removable" 
    ATTRS{idProduct}=="6001" 
    ATTRS{bDeviceClass}=="00" 
    ATTRS{product}=="USB <-> Serial" 

    looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3': 
    KERNELS=="usb3" 
    SUBSYSTEMS=="usb" 
    DRIVERS=="usb" 
    ATTRS{bDeviceSubClass}=="00" 
    ATTRS{bDeviceProtocol}=="01" 
    ATTRS{devpath}=="0" 
    ATTRS{idVendor}=="1d6b" 
    ATTRS{speed}=="480" 
    ATTRS{bNumInterfaces}==" 1" 
    ATTRS{bConfigurationValue}=="1" 
    ATTRS{bMaxPacketSize0}=="64" 
    ATTRS{authorized_default}=="1" 
    ATTRS{busnum}=="3" 
    ATTRS{devnum}=="1" 
    ATTRS{configuration}=="" 
    ATTRS{bMaxPower}=="0mA" 
    ATTRS{authorized}=="1" 
    ATTRS{bmAttributes}=="e0" 
    ATTRS{bNumConfigurations}=="1" 
    ATTRS{maxchild}=="4" 
    ATTRS{bcdDevice}=="0313" 
    ATTRS{avoid_reset_quirk}=="0" 
    ATTRS{quirks}=="0x0" 
    ATTRS{serial}=="0000:00:14.0" 
    ATTRS{version}==" 2.00" 
    ATTRS{urbnum}=="383" 
    ATTRS{ltm_capable}=="no" 
    ATTRS{manufacturer}=="Linux 3.13.0-32-generic xhci_hcd" 
    ATTRS{removable}=="unknown" 
    ATTRS{idProduct}=="0002" 
    ATTRS{bDeviceClass}=="09" 
    ATTRS{product}=="xHCI Host Controller" 

    looking at parent device '/devices/pci0000:00/0000:00:14.0': 
    KERNELS=="0000:00:14.0" 
    SUBSYSTEMS=="pci" 
    DRIVERS=="xhci_hcd" 
    ATTRS{irq}=="40" 
    ATTRS{subsystem_vendor}=="0x17aa" 
    ATTRS{broken_parity_status}=="0" 
    ATTRS{class}=="0x0c0330" 
    ATTRS{enabled}=="1" 
    ATTRS{consistent_dma_mask_bits}=="64" 
    ATTRS{dma_mask_bits}=="64" 
    ATTRS{local_cpus}=="ff" 
    ATTRS{device}=="0x1e31" 
    ATTRS{msi_bus}=="" 
    ATTRS{local_cpulist}=="0-7" 
    ATTRS{vendor}=="0x8086" 
    ATTRS{subsystem_device}=="0x3977" 
    ATTRS{d3cold_allowed}=="1" 

    looking at parent device '/devices/pci0000:00': 
    KERNELS=="pci0000:00" 
    SUBSYSTEMS=="" 
    DRIVERS=="" 

我試圖通過分配KERNELS實現第一溶液@How to distinguish between identical USB-to-serial adapters? ==「3 -1「到ttyUSB0和KERNELS ==」3-2「到ttyUSB1,但它不是持久的,每當我重新連接設備時都會更改。此外ATTRS{devnum}也一直在不斷變化,但可以指出,他們總是在順序。那麼,我可以使用它們來修復設備名稱嗎?我不確定相同的設備將始終使用更小或更大的devnum進行初始化。任何幫助表示讚賞。

+0

移動到[辨別兩個相似的USB設備](http://askubuntu.com/questions/698990/distinguishing-between-two-similar-usb-devices) –

回答

0

KERNELS屬性是設備的總線路徑,只要它們總是插入同一端口(並且該端口位於集線器上,集線器插入同一端口等),該屬性應該一致。由於這兩個設備是相同的,所以沒有其他方式可以區分它們,而不是通過它們連接的端口進行區分。

+0

是的,做了這樣的事情只有通過採取ENV {ID_PATH}'作爲區分參數,因爲設備將保持連接到您正確指出的相同端口。這個問題已經解決,因爲我轉向問Ubuntu。 –