Python : PyUSB can't access usb device

894 views Asked by At

I am trying to read an usb bar code reader from my python script, via the https://github.com/pyusb/pyusb library.

import usb.core
import usb.util
VENDOR_ID = 8208
PRODUCT_ID = 30264


dev = usb.core.find(idVendor=VENDOR_ID,

                       idProduct=PRODUCT_ID)
dev.set_configuration()
cfg = dev.get_active_configuration()
intf = cfg[(0,0)]
ep = usb.util.find_descriptor(
    intf,
    # match the first OUT endpoint
    custom_match = \
    lambda e: \
        usb.util.endpoint_direction(e.bEndpointAddress) == \
        usb.util.ENDPOINT_IN)
data    = ep.read(ep.wMaxPacketSize, 8000000)

Unfortunately, this leads to a "USBError: [Errno 13] Access denied (insufficient permissions)" issue.

I tried to run the script as a sudo, but it didn't help. The script work fine on my Ubuntu laptop, but I am now trying to move it to Mac OS. One of the differences is that I do have a "detach_kernel" before hand on Linux, but this function make a fail with "not implemented on this OS" error with Mac Os...

0

There are 0 answers