Por que minha porta USB consertando as regras do udev não estão funcionando

0

Estou usando o Ubuntu 16.04.1 Server . Há um conjunto de modems conectado à uma porta USB do servidor. Quando o modem é desligado e ligado novamente, os números ttyUSB estão mudando. Eu preciso consertar essas portas. Então, coloco as regras abaixo no arquivo em /etc/udev/rules.d e reinicio o serviço udev com systemctl restart udev.service

# cat /etc/udev/rules.d/86-persistent-gsm-modem.rules 

KERNEL=="ttyUSB*", SUBSYSTEM=="tty", KERNELS=="1-1.5:1.0", DRIVERS=="ftdi_sio", ATTRS{product}=="Quad RS232-HS", ATTRS{manufacturer}=="FTDI", NAME="ttyUSB0"
KERNEL=="ttyUSB*", SUBSYSTEM=="tty", KERNELS=="1-1.5:1.1", DRIVERS=="ftdi_sio", ATTRS{product}=="Quad RS232-HS", ATTRS{manufacturer}=="FTDI", NAME="ttyUSB1"
KERNEL=="ttyUSB*", SUBSYSTEM=="tty", KERNELS=="1-1.5:1.2", DRIVERS=="ftdi_sio", ATTRS{product}=="Quad RS232-HS", ATTRS{manufacturer}=="FTDI", NAME="ttyUSB2"
KERNEL=="ttyUSB*", SUBSYSTEM=="tty", KERNELS=="1-1.5:1.3", DRIVERS=="ftdi_sio", ATTRS{product}=="Quad RS232-HS", ATTRS{manufacturer}=="FTDI", NAME="ttyUSB3"

Quando eu desligo e ligo novamente o modem ainda ttyUSB números estão mudando.

Existe algum problema com regras e como posso verificar se as regras são lidas por udev e executadas?

Inclusão da saída do udevadm para / dev / ttyUSB0, por exemplo.

udevadm info -a /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:1a.0/usb1/1-1/1-1.5/1-1.5:1.0/ttyUSB0/tty/ttyUSB0':
    KERNEL=="ttyUSB0"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5:1.0/ttyUSB0':
    KERNELS=="ttyUSB0"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="ftdi_sio"
    ATTRS{latency_timer}=="1"
    ATTRS{port_number}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5:1.0':
    KERNELS=="1-1.5: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}=="Quad RS232-HS"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5':
    KERNELS=="1-1.5"
    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}=="500mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 4"
    ATTRS{bcdDevice}=="0800"
    ATTRS{bmAttributes}=="80"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{devnum}=="3"
    ATTRS{devpath}=="1.5"
    ATTRS{idProduct}=="6011"
    ATTRS{idVendor}=="0403"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="FTDI"
    ATTRS{maxchild}=="0"
    ATTRS{product}=="Quad RS232-HS"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{speed}=="480"
    ATTRS{urbnum}=="4960883"
    ATTRS{version}==" 2.00"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="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}=="0000"
    ATTRS{bmAttributes}=="e0"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{devnum}=="2"
    ATTRS{devpath}=="1"
    ATTRS{idProduct}=="0020"
    ATTRS{idVendor}=="8087"
    ATTRS{ltm_capable}=="no"
    ATTRS{maxchild}=="6"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="fixed"
    ATTRS{speed}=="480"
    ATTRS{urbnum}=="31"
    ATTRS{version}==" 2.00"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="0404"
    ATTRS{bmAttributes}=="e0"
    ATTRS{busnum}=="1"
    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.4.0-34-generic ehci_hcd"
    ATTRS{maxchild}=="2"
    ATTRS{product}=="EHCI Host Controller"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{serial}=="0000:00:1a.0"
    ATTRS{speed}=="480"
    ATTRS{urbnum}=="24"
    ATTRS{version}==" 2.00"

  looking at parent device '/devices/pci0000:00/0000:00:1a.0':
    KERNELS=="0000:00:1a.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci-pci"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0320"
    ATTRS{companion}==""
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x3b3c"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="16"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{local_cpus}=="000f"
    ATTRS{msi_bus}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{subsystem_device}=="0x8383"
    ATTRS{subsystem_vendor}=="0x1043"
    ATTRS{uframe_periodic_max}=="100"
    ATTRS{vendor}=="0x8086"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    
por Sencer H. 26.08.2016 / 16:33

1 resposta

1

Primeiro, o udev não irá mais renomear os nomes dos dispositivos designados pelo kernel. (Entre outras razões, como ele deve lidar com a solicitação de renomear algo que já foi usado por outro dispositivo?)

Em vez disso, use SYMLINK+="..." para criar links simbólicos em / dev com seus nomes preferidos, por exemplo, SYMLINK+="ttyUSB-port0" . (Na verdade, o padrão 60-serial.rules já deve estar criando links simbólicos em /dev/serial/by-path para você.)

Segundo, as regras são processadas não quando o udev é iniciado, mas apenas quando o kernel envia uevents indicando um dispositivo novo ou alterado. Para causar isso manualmente, você precisa de udevadm trigger -s tty (ou apenas reconecte o dispositivo).

    
por 26.08.2016 / 17:07