Frage

I am writting an udev rule to set name of two serial ports. I want to use the value of the attribute bInterfaceNumber in the symlink.

My rules is:

SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", SYMLINK+="toto%s{bInterfaceNumber}"

The rule matched the device but value of the attribute is never found.

Here is the hierarchical view of one device:

console@host:udevadm info --name=/dev/ttyUSB0 --attribute-walk
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0':
    KERNELS=="1-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="ftdi_sio"
    ATTRS{bInterfaceNumber}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{idVendor}=="0403"
    ATTRS{idProduct}=="6010"

Thanks in advance

War es hilfreich?

Lösung

This is rule I made to create an alias for dual port FTDI chip:

# Internal serial ports
SUBSYSTEMS=="usb", ATTRS{interface}=="Dual RS232", SYMLINK+="sertest%s{bInterfaceNumber}"

According to this post the attributes must be matching on one level. That's why idVendor and idProduct won't work with bInterfaceNumber. Below you can see, that interface and bInterfaceNumber belong to the same level:

looking at parent device '/devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0':
KERNELS=="1-1.2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="ftdi_sio"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bNumEndpoints}=="02"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceSubClass}=="ff"
ATTRS{bInterfaceProtocol}=="ff"
ATTRS{supports_autosuspend}=="1"
ATTRS{interface}=="Dual RS232"

Andere Tipps

I think you can use environmental variables like that.

In your case it will be something like this:

SUBSYSTEM=="usb", DRIVER=="ftdi_sio", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010" ENV{MY_DEV}="yes"

ENV{MY_DEV}="yes", SUBSYSTEMS=="usb", SYMLINK+="toto%s{bInterfaceNumber}"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top