linuxubuntuusblibusbudev

Udev rules are not working for libusb on Ubuntu 12.04


I'm on Ubuntu 12.04.5 LTS, x86_64.

I've a usb device that uses libusb to communicate with the computer. Once I plug it into the computer and run the communication program I get the following error:

libusb couldn't open USB device /dev/bus/usb/008/004: Permission denied.
libusb requires write access to USB device nodes.
libusb failed to find the Optotrak USB device.  Are you sure you have set the udev permissions correctly?

So if I chmod the /dev/bus/usb/008/004 as follows:

sudo chmod 777 /dev/bus/usb/008/004

and run the communication program again, then the device works perfectly. The problem is that every time I plug the device, the last number changes, so I should have to chmod every time the usb bus, but since not all users know the administrator password this is a problem.

So the manufacturer suggest to edit the udev rules as follows. Create a 12-ndi-rules inside /etc/udev/rules.d :

BUS=="usb", SYSFS{idVendor}=="0403", SYSFS{idProduct}=="da77", GROUP="plugdev"

(I've checked with lsusb that SYSFS are correct)

lsusb 

Bus 008 Device 004: ID 0403:da77 Future Technology Devices International, Ltd 

and then reload the rules:

sudo udevadm control --reload-rules

but still the permissions for bus 008/004 are not correctly set.

How do I make these rules permament at every reboot? I would also like to get make them permanent also if I change the port of the usb device.


Solution

  • Unless you have a really old udev, the rule is wrong, it should be :

    SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="da77", GROUP="plugdev"
    

    Putting the rule in a file in /etc/udev/rules.d/ is the correct way to make it permanent.

    Other things you can put in a rule file are in the man page.