2

this question was asked several times with regards to generic USB devices. However, udev approach doesn't seem to work with HIDRAW devices.

I've tried to write something like the following to /etc/udev/rules.d/10-local.rules:

 ACTION=="add", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="16d6", ATTRS{product}=="JA-100 Flexi", SYMLINK+="my_device"

But this maps parent USB device, not the HIDRAW one. So, how can I persist the name for hidraw in case it changes after reconnect from, say, hidraw0 to hidraw1?

Andrey
  • 21

1 Answers1

0

First you need to find the hidraw device

dmesg | grep "hidraw"

Then you need to get its attributes

udevadm info --name=/dev/hidraw* --attribute-walk

where * is the number of the device (e.g. hidraw5). From this you'll need to find the ATTRS{id}.

Then create a rules file on RPi with the following:

sudo nano /etc/udev/rules.d/10-usb-serial.rules

modify the file with the following:

SUBSYSTEM=="hidraw", ATTRS{id}=="00241011", SYMLINK+="hidraw_static"

where ATTRS{id} is the device's id from earlier and SYMLINK is the name you choose.

Run the following commands after saving this file

sudo udevadm control --reload
sudo udevadm trigger

Check that the new name points to the correct hidraw*

ls -l /dev/hidraw_static

should look something like this

lrwxrwxrwx 1 root root 7 Dec 14 10:41 /dev/hidraw_static -> hidraw6

This worked for a Bluetooth-connected barcode scanner connected to a RPi 3b+.

Stephen Kitt
  • 434,908
Zach
  • 1