这个问题像世界一样古老。有讨论和解决方案。这一切都归结为更新规则文件并授予权限。所以我按照食谱。但我仍然有同样的问题。这是截图显示我按照说明。
版本:
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
usb.__version__ '1.0.2'
错误:
Traceback (most recent call last):
File "/media/psf/Home/All-Projects-on-femto/LaserLab/Software/usb_4108.py", line 19, in <module>
dev.set_configuration()
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 869, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 147, in managed_set_configuration
self.managed_open()
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 120, in managed_open
self.handle = self.backend.open_device(self.dev)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 786, in open_device
return _DeviceHandle(dev)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 643, in __init__
_check(_lib.libusb_open(self.devid, byref(self.handle)))
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
USBError: [Errno 13] Access denied (insufficient permissions)
规则。档案(位置/etc/udev/rules.d/99-usbftdi.rules)
# For FTDI FT232 & FT245 USB devices with Vendor ID = 0x0403, Product ID = 0xabc
SYSFS{idProduct}=="4108", SYSFS{idVendor}=="0683", RUN+="/sbin/modprobe -q ftdi-sio product=0x4108 vendor=0x0683"
#SYSFS{idProduct}=="2450", SYSFS{idVendor}=="0683", RUN+="/sbin/modprobe -q ftdi-sio product=0x2450 vendor=0x0683"
SYSFS{idVendor}=="0683", SYSFS{idProduct}=="4108", MODE="0666"
并删除代码:
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
dev.reset()
但是,它并没有给我必要的权限。 我的精简代码仍会产生错误:
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
dev.reset()
奇怪的是,如果我作为超级用户从终端启动IDLE,我将获得权限(终端:sudo idle
)。
答案 0 :(得分:2)
你的规则看起来有点奇怪。你可以删除所有这些并试试吗?
SUBSYSTEM=="usb", ATTRS{idVendor}=="0683", MODE="0666"