I'm using a USB <-> Serial box and would like to have a custom symlink for the serial ports.
Based on the output of udevadm
I know each port has a different KERNELS value:
KERNELS=="1-3:1.0" (this is labeled as port 1 on the box)
KERNELS=="1-3:1.1" (port 2)
KERNELS=="1-3:1.2" (port 3)
KERNELS=="1-3:1.3" (port 4)
I tried the following rule:
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", KERNELS=="1-3:1.3", SYMLINK+="my_port"
which did not work. If, however, I use KERNELS=="1-3"
instead of KERNELS=="1-3:1.3"
, the symlink is created.
How can I rewrite the rule to be able to differentiate between the various serial ports?
$ udevadm info --path=/sys/bus/usb-serial/devices/ttyUSB19 --attribute-walk
looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.3/ttyUSB19':
KERNEL=="ttyUSB19"
SUBSYSTEM=="usb-serial"
DRIVER=="ftdi_sio"
ATTR{latency_timer}=="16"
ATTR{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.3':
KERNELS=="1-3:1.3"
SUBSYSTEMS=="usb"
DRIVERS=="ftdi_sio"
ATTRS{authorized}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceNumber}=="03"
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/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}==" 4"
ATTRS{bcdDevice}=="0800"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="1"
ATTRS{configuration}==""
ATTRS{devnum}=="65"
ATTRS{devpath}=="3"
ATTRS{idProduct}=="6011"
ATTRS{idVendor}=="0403"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="FTDI"
[...]
KERNELS=="1-3"
, you probably get a symlink to the raw USB device instead of the tty. You need to match onSUBSYSTEM=="usb-serial"
(or whatever subsystem actually produces the tty). This question is a duplicate, and has been asked before in several variants, but I don't have the time to find the old question(s) right now.