Este es el contenido de mi archivo de reglas para varios dispositivos usb
# cat /etc/udev/rules.d/50-usb-serial.rules
SUBSYSTEMS=="usb-serial",DRIVERS=="cp210x",ATTRS{port_number}=="0",SYMLINK+="obd15a"
SUBSYSTEMS=="usb", KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A9U9DF7V", SYMLINK+="obd"
SUBSYSTEMS=="usb", KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="00000000", SYMLINK+="sim-ecu"
Para ello:
# sudo udevadm info -q path -n /dev/ttyUSB4
/devices/pci0000:00/0000:00:1d.3/usb5/5-1/5-1:1.0/ttyUSB4/tty/ttyUSB4
# sudo udevadm info -a -p /devices/pci0000:00/0000:00:1d.3/usb5/5-1/5-1:1.0/ttyUSB4/tty/ttyUSB4
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:1d.3/usb5/5-1/5-1:1.0/ttyUSB4/tty/ttyUSB4':
KERNEL=="ttyUSB4"
SUBSYSTEM=="tty"
DRIVER==""
looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb5/5-1/5-1:1.0/ttyUSB4':
KERNELS=="ttyUSB4"
SUBSYSTEMS=="usb-serial"
DRIVERS=="cp210x"
ATTRS{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb5/5-1/5-1:1.0':
KERNELS=="5-1:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bNumEndpoints}=="02"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceSubClass}=="00"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{modalias}=="usb:v10C4pEA60d0100dc00dsc00dp00icFFisc00ip00"
ATTRS{supports_autosuspend}=="0"
ATTRS{interface}=="CP2102 USB to UART Bridge Controller"
looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb5/5-1':
KERNELS=="5-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{configuration}==""
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bmAttributes}=="80"
ATTRS{bMaxPower}=="100mA"
ATTRS{urbnum}=="53123"
ATTRS{idVendor}=="10c4"
ATTRS{idProduct}=="ea60"
ATTRS{bcdDevice}=="0100"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bNumConfigurations}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{speed}=="12"
ATTRS{busnum}=="5"
ATTRS{devnum}=="2"
ATTRS{version}==" 1.10"
ATTRS{maxchild}=="0"
ATTRS{quirks}=="0x0"
ATTRS{authorized}=="1"
ATTRS{manufacturer}=="Silicon Labs"
ATTRS{product}=="CP2102 USB to UART Bridge Controller"
ATTRS{serial}=="0001"
looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb5':
KERNELS=="usb5"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{configuration}==""
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bMaxPower}==" 0mA"
ATTRS{urbnum}=="55"
ATTRS{idVendor}=="1d6b"
ATTRS{idProduct}=="0001"
ATTRS{bcdDevice}=="0206"
ATTRS{bDeviceClass}=="09"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bNumConfigurations}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{speed}=="12"
ATTRS{busnum}=="5"
ATTRS{devnum}=="1"
ATTRS{version}==" 1.10"
ATTRS{maxchild}=="2"
ATTRS{quirks}=="0x0"
ATTRS{authorized}=="1"
ATTRS{manufacturer}=="Linux 2.6.32.atom.mh.01 uhci_hcd"
ATTRS{product}=="UHCI Host Controller"
ATTRS{serial}=="0000:00:1d.3"
ATTRS{authorized_default}=="1"
looking at parent device '/devices/pci0000:00/0000:00:1d.3':
KERNELS=="0000:00:1d.3"
SUBSYSTEMS=="pci"
DRIVERS=="uhci_hcd"
ATTRS{vendor}=="0x8086"
ATTRS{device}=="0x27cb"
ATTRS{subsystem_vendor}=="0x8086"
ATTRS{subsystem_device}=="0x574d"
ATTRS{class}=="0x0c0300"
ATTRS{irq}=="16"
ATTRS{local_cpus}=="f"
ATTRS{local_cpulist}=="0-3"
ATTRS{modalias}=="pci:v00008086d000027CBsv00008086sd0000574Dbc0Csc03i00"
ATTRS{enable}=="1"
ATTRS{broken_parity_status}=="0"
ATTRS{msi_bus}==""
looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
La parte que nos interesa es:
KERNELS=="ttyUSB4"
SUBSYSTEMS=="usb-serial"
DRIVERS=="cp210x"
ATTRS{port_number}=="0"
Y si es necesario (como ha sido mi caso):
ATTRS{serial}=="0001"
Con esto hacemos un archivo de reglas en /etc/udev/rules.d llamado "50-usb-serial.rules" con el siguiente contenido
SUBSYSTEMS=="usb-serial",DRIVERS=="cp210x",ATTRS{port_number}=="0",SYMLINK+="aag-weather"
Y ejecutamos el siguiente comando para que se ejecute la regla de forma inmediata
# sudo udevadm trigger
No hay comentarios:
Publicar un comentario