2

I am trying to connect to my USB bar-code reader, but bump into a lack of rights to open it under Mac OS 10.14.6. I am trying to use this library: https://github.com/vpelletier/python-libusb1 the lack of documentation is a bit annoying.

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...

Is there anyone having a clue on what to do ? The error is :

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]

There is some hints :

  1. seems like we should set up rights somewhere, but these pages are about ubuntu : => https://askubuntu.com/questions/978552/how-do-i-make-libusb-work-as-non-root => https://github.com/vpelletier/python-libusb1/issues/34
  2. here are some things about Mac OS, but it is unclear to me : => IOCreatePlugInInterfaceForService returns mysterious error => OpenCV command line app can't access camera under macOS Mojave
Romain Jouin
  • 4,448
  • 3
  • 49
  • 79
  • Hello, I am not sure how to help you, but have you tried https://github.com/karpierz/libusb it explicitly states that no elevated user privileges needed. – sleepyhead Oct 13 '20 at 21:59
  • It also says "currently works and tested only for Windows" => I will try it on windows anyway, to have a look. Thanks ! – Romain Jouin Oct 14 '20 at 09:42

0 Answers0