Udev规则不适用于Ubuntu 12.04上的libusb [英] Udev rules are not working for libusb on Ubuntu 12.04
问题描述
我使用的是Ubuntu 12.04.5 LTS x86_64.
I'm on Ubuntu 12.04.5 LTS, x86_64.
我有一个使用libusb与计算机通信的USB设备. 将其插入计算机并运行通信程序后,出现以下错误:
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?
因此,如果我按如下所示对/dev/bus/usb/008/004进行chmod修改:
So if I chmod the /dev/bus/usb/008/004 as follows:
sudo chmod 777 /dev/bus/usb/008/004
,然后再次运行通信程序,则设备可以正常运行. 问题在于,每次插入设备时,最后一个数字都会更改,因此每次USB总线时我都必须使用chmod,但是由于并非所有用户都知道管理员密码,所以这是一个问题.
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.
因此,制造商建议如下编辑udev规则.在/etc/udev/rules.d内创建一个12-ndi-rules:
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"
(我已经与lsusb确认SYSFS是正确的)
(I've checked with lsusb that SYSFS are correct)
lsusb
Bus 008 Device 004: ID 0403:da77 Future Technology Devices International, Ltd
,然后重新加载规则:
sudo udevadm control --reload-rules
但仍然未正确设置总线008/004的权限.
but still the permissions for bus 008/004 are not correctly set.
如何在每次重新启动时使这些规则保持不变?如果更改USB设备的端口,我也希望使它们永久化.
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.
推荐答案
除非您拥有真正的udev,否则规则是错误的,应该是:
Unless you have a really old udev, the rule is wrong, it should be :
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}=="da77", GROUP="plugdev"
将规则放入/etc/udev/rules.d/
中的文件是使其永久化的正确方法.
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.
这篇关于Udev规则不适用于Ubuntu 12.04上的libusb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!