Udev Rules Are Not Working for Libusb on Ubuntu 12.04

Udev rules are not working for libusb on Ubuntu 12.04

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.

libusb calls without sudo using udev-rules

I suggest that you add a new file in /etc/udev/rules.d named usb.rules. It should have the following contents:

SUBSYSTEM=="usb", MODE="0666"

This will make all USB devices readable and writable by all users.

You could also narrow it down to specific USB devices using idVendor and idProduct attributes mentioned in Ignacio's answer.

libusb cannot open USB device, permission isse. NetBeans/Ubuntu

Well you can run your application in root user mode and get rid with the permission
issue. However you should be aware about the consequences of running the program in
root user and should not be do until you fully understand the user/group permission
on UNIX based system. However if it is your test machine, i think you can do the
following(for program name ./a.out):

  1. Open the terminal
  2. Go to the directory where your program executable is present(check your netbeans creates the project and type cd completepath).
  3. sudo ./a.out
  4. Now command prompt would ask to enter root password

Now you should be able to run the program successfully.

However if you want to provide/change the permission of read/write/execute for a particular user you should try to understand about chmod command. You would have to change the permission to directory(/dev/bus/usb/002/) and any particular file residing under this directory. Hope this information would be useful.

Linux udev rule does not appear to work

Modifiying permissions for USB devices seems to be handled at least 3 different ways depending on the version of Linux (HAL, udev, hotplug, etc.). After several unsuccessful attempts I finally came across a site with accurate information.

For Linux 2.6.11 at least, the answer is hotplug. The solution is to create a custom usermap file in /etc/hotplug/usb. Use the built-in usermap (/etc/hotplug/usb.usermap) as an example. The usermap file specifies a script to execute when a matching device is connected. The script should also be located in /etc/hotplug/usb.

For example, I created /etc/hotplug/usb/myusbdvc.usermap with the VID and PID of my device and a script to execute named chmodmyusbdvc.

I also created /etc/hotplug/usb/chmodmyusbdvc with the follow contents:

#!/bin/bash
if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
echo "changing ${DEVICE}" >> /tmp/debug-hotplug
chmod 666 "${DEVICE}"
fi

Run something when USB device is plugged in doesn't work

I'm not an expert and this isn't an answer, but I've found the following steps useful in identifying the appropriate attributes to trigger on:

  1. Locate the device path using udevadm, lsusb, or usb-devices. I normally just use lsusb and let tab completion in my shell guide me. In my case, the path is /dev/bus/usb/003/007.
  2. Use udevadm to identify the device attributes for rule writing. In my case, I used udevadm info -a --attribute-walk --root --name=/dev/bus/usb/003/007.
  3. Write the rule and check that it's triggering. In my case, I'm just changing the device owner to user "stephen" and it's very easy for me to check if it's working by using ls -l /dev/bus/usb/003/007. My rule for this case looks like: SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", OWNER="stephen". I have a similar rule that puzzled me for a little while because the subsystem was expecting ATTRS not ATTR, which is why I recommend walking the attributes. The rule in this latter case became: `SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", OWNER="stephen".

And, of course, man udev is always helpful. As you said, you should struggle to identify that your rule is triggering properly and may be best off just doing a quick ownership change on the device as I did for a first step. You can run into trouble with bad attributes or symbolic links sometimes and it's



Related Topics



Leave a reply



Submit