3

I have a Mono application running on Raspbian that uses a certain USB device through libusb. If I start the application normally it fails to open the device. If I start the application as root (or through sudo) the application successfully opens the device.

How can I give the application or user the proper permissions for the USB device so that the application doesn't have to be started as root?

TheHvidsten
  • 181
  • 2
  • 10

1 Answers1

1

To give a specific group access to a USB device you have to add a rule to udev in /etc/udev/rules.d/. I added a file called 50-MyDevice.rules that contains this line:

SUBSYSTEM=="usb",ATTRS{idVendor}=="abcd",ATTRS{idProduct}=="1234",MODE="0660",GROUP="mygroup",SYMLINK+="mydevice%n"

Where I have replaced the values after idVendor and idProduct with the USB device's VID and PID. Pay special attention to the number of equal signs after each parameter!

After this I rebooted linux.

Now, every time I plug in the USB device (or if I plug in several of the same device) I get a symlink called /dev/mydevice1 or /dev/mydevice2. This is a symlink pointing to /dev/bus/usb/001/001 (or in the second case /dev/bus/usb/001/002). The targets of these symlinks have the the proper mode and group permissions defined in the rules file.

TheHvidsten
  • 181
  • 2
  • 10