0

I have a Prolific serial adapter. When I attach it, it gets the name ttyUSB0. I have created the file /etc/udev/rules.d/99-serial.rules with the following content

KERNELS=="1-2", SUBSYSTEM=="tty", SYMLINK="prolific"

This is working well, and I can access /dev/prolific! (I know that I am overwriting other symbolic links by not using +=).

Now my question: is it possible to control the 'primary' name of the device (ttyUSB0) like so:

KERNELS=="1-2", SUBSYSTEM=="tty", NAME="prolific"

I have not been able make this work.

Here is the relevant (?!) output of udevadm info -a /dev/ttyUSB0:

looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/ttyUSB0/tty/ttyUSB0':
    KERNEL=="ttyUSB0"
    SUBSYSTEM=="tty"
    DRIVER==""    
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/ttyUSB0':
    KERNELS=="ttyUSB0"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="pl2303"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0':
    KERNELS=="1-2:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="pl2303"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2':
    KERNELS=="1-2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
looking at parent device '/devices/pci0000:00/0000:00:14.0':
    KERNELS=="0000:00:14.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{waiting_for_supplier}=="0"

Background: on a different machine, there are tons of test scripts which are using the device names ttyACM0 and ttyACM1. Unfortunately, the two devices are getting swapped every now and then when rebooting the machine. People have taken the pain and un/replugged the devices in the right order after each reboot, which is no longer acceptable. I could now change all the scripts and use symbolic links as described above, or I could try to assign fixed names to the devices, which in my eyes would be the superior solution by far.

All the solutions I have found put additional names on top but do not touch the names assigned by the system.

HJP
  • 1
  • You cannot change the kernel name. Just create symlinks, and modify your code to use those. You'll be better off if you can match on vendor/product codes rather than KERNELS. – larsks Jun 14 '22 at 15:17
  • You cannot change the name of a device /dev/tty*. @larsks makes a good point. Please, see https://unix.stackexchange.com/a/120272/72707. – Cbhihe Jun 14 '22 at 17:05

0 Answers0