问题描述
我试图连接到我的USB条形码阅读器,但遇到在Mac OS 10.14.6下无法打开它的权利。 我正在尝试使用此库:https://github.com/vpelletier/python-libusb1缺少文档有点烦人。
import usb1
vendOR_ID = 8208
PRODUCT_ID = 30264
INTERFACE = 0
with usb1.USBContext() as context:
handle = context.openByvendorIDAndProductID(
vendOR_ID,PRODUCT_ID,skip_on_error=False,)
if handle is None:
# Device not present,or user is not allowed to access device.
print("no handle")
with handle.claimInterface(INTERFACE):
print("handle = ",handle)
# Do stuff with endpoints on claimed interface.
while True:
data = handle.bulkRead(ENDPOINT,BUFFER_SIZE)
# Process data...
有人知道该怎么做吗? 错误是:
USBErrorAccess Traceback (most recent call last)
<ipython-input-1-217d9879b039> in <module>
12 # Device not present,or user is not allowed to access device.
13 print("no handle")
---> 14 with handle.claimInterface(INTERFACE):
15 print("handle = ",handle)
16 # Do stuff with endpoints on claimed interface.
/Applications/anaconda3/lib/python3.7/site-packages/usb1/__init__.py in claimInterface(self,interface)
1307 """
1308 mayRaiseUSBError(
-> 1309 libusb1.libusb_claim_interface(self.__handle,interface),1310 )
1311 return _ReleaseInterface(self,interface)
/Applications/anaconda3/lib/python3.7/site-packages/usb1/__init__.py in mayRaiseUSBError(value,__raiseUSBError)
131 ):
132 if value < 0:
--> 133 __raiseUSBError(value)
134 return value
135
/Applications/anaconda3/lib/python3.7/site-packages/usb1/__init__.py in raiseUSBError(value,__STATUS_TO_EXCEPTION_DICT,__USBError)
123 __USBError=USBError,124 ):
--> 125 raise __STATUS_TO_EXCEPTION_DICT.get(value,__USBError)(value)
126
127 def mayRaiseUSBError(
USBErrorAccess: LIBUSB_ERROR_ACCESS [-3]
有一些提示:
- 似乎我们应该在某个地方设置权限,但是这些页面是关于ubuntu的: => https://askubuntu.com/questions/978552/how-do-i-make-libusb-work-as-non-root => https://github.com/vpelletier/python-libusb1/issues/34
- 以下是有关Mac OS的一些信息,但我不清楚: => IOCreatePlugInInterfaceForService returns mysterious error => OpenCV command line app can't access camera under macOS Mojave
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)