Extra criado / dev / ttyUSB bloqueia o uso de um arquivo-config personalizado do udev config-ed

0

Sou um mergulhador e orgulhoso proprietário de 2 computadores de mergulho. Estes dois podem ser conectados a uma porta USB e com o programa de registro de mergulho SubSurface da Linus eu posso importar logs de mergulho deles. Um é um Cobalto Aquático Atômico e o outro é um Suunto D4i. Agora eu quero criar arquivos dev com o udev para cada um deles, para que eu possa conectá-los a qualquer porta USB e ainda usar o mesmo arquivo dev no software de registro. (Por exemplo, / dev / my_cobalt e / dev / my_d4i)

A mesma configuração (tipo de) é usada para ambos.
Para o D4i o uso do arquivo dev é bloqueado por um / dev / ttyUSB0 criado automaticamente.
Para os dois computadores de mergulho, o arquivo de desenvolvimento é criado e, para o Cobalt, funciona como desejado, mas não para o D4i.
Eu posso usar / dev / ttyUSB0 mas não / dev / my_d4i.

De alguma forma, parece (não tenho certeza) ser causada por uma diferença na forma como eles se apresentam para o barramento USB. Veja a saída do lsusb abaixo.

Se alguém puder me dizer o que causa essa diferença e / ou como resolver isso, eu realmente aprecio isso. (Por que quando conectando o d4i também é criado um arquivo dev ttyUSB?)

Abaixo, algumas informações sobre descobertas / configurações.

/etc/udev/rules.d/dive-computers.rules

# My Cobalt2 DiveComputer
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", ATTR{idProduct}=="0888", SYMLINK+="my_cobalt", GROUP="dialout", MODE="0660"
# My Suunto D4i DiveComputer
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="6001", SYMLINK+="my_d4i", GROUP="dialout", MODE="0660"

dev-files depois de conectar o Cobalt

lrwxrwxrwx   1 root root            15 mei 16 23:13 my_cobalt -> bus/usb/003/007
# no ttyUSB0 created

dev-files depois de conectar o d4i

lrwxrwxrwx   1 root root            15 mei 16 23:15 my_d4i -> bus/usb/003/009
crw-rw----   1 root dialout   188,   0 mei 16 23:15 ttyUSB0

lsusb -v -D / dev / bus / usb / 003/007 (Cobalto)

Device: ID 0471:0888 Philips (or NXP) Hantek DDS-3005 Arbitrary Waveform Generator
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          220 Diagnostic
  bDeviceSubClass         1 Reprogrammable Diagnostics
  bDeviceProtocol         1 USB2 Compliance
  bMaxPacketSize0        16
  idVendor           0x0471 Philips (or NXP)
  idProduct          0x0888 Hantek DDS-3005 Arbitrary Waveform Generator
  bcdDevice            0.02
  iManufacturer           1 ATOMIC AQUATICS
  iProduct                2 COBALT
  iSerial                 3 123456789ABCDEF
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          4 Console
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       220 Diagnostic
      bInterfaceSubClass    160 
      bInterfaceProtocol    176 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0101
  Self Powered

lsusb -v -D / dev / barramento / usb / 003/009 (D4i)

Device: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0403 Future Technology Devices International, Ltd
  idProduct          0x6001 FT232 USB-Serial (UART) IC
  bcdDevice            6.00
  iManufacturer           1 Smartinterface
  iProduct                2 USB  Serial Cable
  iSerial                 3 DiYISDGK
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              2 USB  Serial Cable
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0000
  (Bus Powered)

registro do software (pelo que vale a pena)

Starting download from  /dev/my_d4i
Starting the thread 0
[0.000126] ERROR: Inappropriate ioctl for device (25) [in ../../src/serial_posix.c:308 (dc_serial_open)]
[0.000156] ERROR: Failed to open the serial port. [in ../../src/suunto_d9.c:155 (suunto_d9_device_open)]
INFO: dc_deveice_open error value of -6
Finishing the thread Unable to open %s %s (%s) dives downloaded 0
Starting download from  /dev/ttyUSB0
Starting the thread 0
INFO: dc_deveice_open error value of 0
Finishing the thread  dives downloaded 0

    
por Pjotr133 17.05.2018 / 00:04

1 resposta

0

Então dirkt fez um comentário que me fez pensar e eu verifiquei alguns fatos novamente. Com o monitor do udevadm e, em seguida, conectando os dispositivos, obtive o seguinte:

Cobalt :

KERNEL[25393.161856] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8 (usb)
KERNEL[25393.165873] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0 (usb)
KERNEL[25393.165941] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-8 (usb)
UDEV  [25393.183044] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8 (usb)
UDEV  [25393.185175] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0 (usb)
UDEV  [25393.186958] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-8 (usb)

D4i

KERNEL[24333.615580] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8 (usb)
KERNEL[24333.618406] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0 (usb)
KERNEL[24333.618444] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0/ttyUSB0 (usb-serial)
KERNEL[24333.618615] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0/ttyUSB0/tty/ttyUSB0 (tty)
KERNEL[24333.618644] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0/ttyUSB0 (usb-serial)
KERNEL[24333.618685] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0 (usb)
KERNEL[24333.618729] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-8 (usb)
UDEV  [24333.637591] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8 (usb)
UDEV  [24333.639773] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0 (usb)
UDEV  [24333.641366] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0/ttyUSB0 (usb-serial)
UDEV  [24333.648159] add      /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0/ttyUSB0/tty/ttyUSB0 (tty)
UDEV  [24333.648969] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0/ttyUSB0 (usb-serial)
UDEV  [24333.649799] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0 (usb)
UDEV  [24333.650906] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-8 (usb)

Com isso, imaginei que os subsistemas do udev corretos deveriam ser:

  • d4i - > tty
  • cobalto - > usb

E como dirkt mencionou, use ATTRS ao invés de ATTR para combinar em todo o devicepath. Então eu mudei as regras do udev para:

# My Cobalt2 DiveComputer
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", ATTR{idProduct}=="0888", SYMLINK+="my_cobalt", GROUP="dialout", MODE="0660"
# My Suunto D4i DiveComputer
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="DiYISDGK", SYMLINK+="my_d4i", GROUP="dialout", MODE="0660"

Depois de reiniciar o udev e reconectar o dispositivo que recebi:

ls -l / dev / tty_d4i

lrwxrwxrwx   1 root root             7 mei 22 00:43 tty_d4i -> ttyUSB0

E isso fez funcionar como eu queria. Eu ainda não estou 100% certo porque, mas esse é o meu conhecimento limitado do udev, eu acho. Eu continuarei investigando o udev, mas por enquanto isso parece estar resolvido. Então, graças ao dirkt pela dica.

Para referência, a saída de:

sudo udevadm info -a -n / dev / ttyUSB0

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/usb3/3-7/3-7:1.0/ttyUSB0/tty/ttyUSB0':
    KERNEL=="ttyUSB0"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-7/3-7:1.0/ttyUSB0':
    KERNELS=="ttyUSB0"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="ftdi_sio"
    ATTRS{latency_timer}=="16"
    ATTRS{port_number}=="0"

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

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb3/3-7':
    KERNELS=="3-7"
    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}=="8"
    ATTRS{bMaxPower}=="500mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="0600"
    ATTRS{bmAttributes}=="a0"
    ATTRS{busnum}=="3"
    ATTRS{configuration}==""
    ATTRS{devnum}=="14"
    ATTRS{devpath}=="7"
    ATTRS{idProduct}=="6001"
    ATTRS{idVendor}=="0403"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Smartinterface"
    ATTRS{maxchild}=="0"
    ATTRS{product}=="USB  Serial Cable"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="removable"
    ATTRS{serial}=="DiYISDGK"
    ATTRS{speed}=="12"
    ATTRS{urbnum}=="15"
    ATTRS{version}==" 2.00"

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

  looking at parent device '/devices/pci0000:00/0000:00:14.0':
    KERNELS=="0000:00:14.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0330"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{dbc}=="disabled"
    ATTRS{device}=="0x8d31"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="19"
    ATTRS{local_cpulist}=="0-11"
    ATTRS{local_cpus}=="fff"
    ATTRS{msi_bus}=="1"
    ATTRS{numa_node}=="0"
    ATTRS{revision}=="0x05"
    ATTRS{subsystem_device}=="0x7a54"
    ATTRS{subsystem_vendor}=="0x1462"
    ATTRS{vendor}=="0x8086"

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

Tags