1

I have a USBTMC device that has a usbtmc interface. The interface has bInterfaceClass, bInterfaceSubClass, and bInterfaceProtocol attributes with values 'fe', '3', and '1' respectively. The question is how to write a udev rule that matches attributes on an interface of the device. It appears that matching starts the device level, and can only look "upward" at the device's parents, but cannot look "downward" (down the sysfs tree) into the device's interface(s).

I'm able to write a working rule that matches based on the VID/PID:

SUBSYSTEM=="usb", ATTR{idProduct}=="5c18", ATTR{idVendor}=="2a8d", MODE:="0660", GROUP="plugdev"

but a rule like this does NOT work:

SUBSYSTEM=="usb", ATTR{bInterfaceClass}=="fe", ATTR{bInterfaceSubClass}=="03", MODE:="0660", GROUP="plugdev"

The following shows a listing of the device, and shows the attributes of the interface found under 1-1:1.0:

me@box:/sys/bus/usb/devices/1-1$ ls
1-1:1.0            bcdDevice            bDeviceProtocol  bMaxPacketSize0     bNumInterfaces  descriptors  devpath  idProduct    manufacturer  power    removable  serial     tx_lanes  version
authorized         bConfigurationValue  bDeviceSubClass  bMaxPower           busnum          dev          driver   idVendor     maxchild      product  remove     speed      uevent
avoid_reset_quirk  bDeviceClass         bmAttributes     bNumConfigurations  configuration   devnum       ep_00    ltm_capable  port          quirks   rx_lanes   subsystem  urbnum
me@box:/sys/bus/usb/devices/1-1$ cat 1-1\:1.0/bInterfaceClass 
fe
me@box:/sys/bus/usb/devices/1-1$ cat 1-1\:1.0/bInterfaceSubClass 
03
me@box:/sys/bus/usb/devices/1-1$ cat 1-1\:1.0/bInterfaceProtocol 
01
me@box:/sys/bus/usb/devices/1-1$

The command: udevadm info -a -n

lists device ATTR that can be used, as well as parent ATTRS. None of these include the (child) interface attributes.

Any help would be appreciated.

1 Answer 1

2

Looks like the answer is to use ENV with ID_USB_INTERFACES, e.g.:

SUBSYSTEM=="usb", ENV{ID_USB_INTERFACES}==":fe0301:", ...

I found this using the libudev API, and enumerating the property names/values for my device, which looks (in part), like this:

ID_BUS : usb
ID_MODEL_ID : 5c18
ID_REVISION : 0100
...
ID_USB_INTERFACES : :fe0301:

Also, the following will dump device properties that can (apparently) be used with ENV in udev rules:

udevadm info --query all <device node>

or

udevadm monitor --udev --subsystem-match=usb --property

and then plug in your (usb) device, and you'll see a property listing.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.