Reputation: 1
I have been trying to intersect usb input with libusb. I can successfully detect and connect to the device but unable to read from the device.
I have a monitoring device which i works perfectly with it own software. but i need to get the data to python for further analysis.
import usb.core
dev = usb.core.find(idVendor=0x09da, idProduct=0xc10a)
import usb1
with usb1.USBContext() as context:
handle = context.openByVendorIDAndProductID(0x09DA,0xC10A,skip_on_error=True)
Ep = dev[0][(0,0)][0]
while True:
data = handle.bulkRead(0x5, 8)
OSError Traceback (most recent call last) in 4 Ep = dev[0][(0,0)][0] 5 while True: ----> 6 data = handle.bulkRead(0x5, 8)
c:\users\admin\appdata\local\programs\python\python36\lib\site-packages\usb1__init__.py in bulkRead(self, endpoint, length, timeout) 1567 data, data_buffer = create_binary_buffer(length) 1568 try: -> 1569 transferred = self._bulkTransfer(endpoint, data, length, timeout) 1570 except USBErrorTimeout as exception: 1571 exception.received = data_buffer[:exception.transferred]
c:\users\admin\appdata\local\programs\python\python36\lib\site-packages\usb1__init__.py in _bulkTransfer(self, endpoint, data, length, timeout) 1516 try: 1517 mayRaiseUSBError(libusb1.libusb_bulk_transfer( -> 1518 self.__handle, endpoint, data, length, byref(transferred), timeout, 1519 )) 1520 except USBErrorTimeout as exception:
OSError: exception: access violation reading 0x0000000000000040
Upvotes: 0
Views: 1707
Reputation: 11
I had similar OSError when using usb.core.
OSError: exception: access violation writing 0x0000000000000024
And I tried couple of changes suggested here in - https://github.com/pyusb/pyusb/issues/203
Used patch from git, since its not released in PyPi https://github.com/pyusb/pyusb
Used libusb to 1.0.22 DLL
this reduced the frequency of the exception occurrence but didnt solve for me.
Then, I tried this -
dev = usb.core.find(find_all=True)
dev.set_configuration() # added this line
I havent seen the exception to occur so far. Hope this helps.
I havent tried but, maybe try applying this patch (suggested in https://github.com/pyusb/pyusb/issues/203) - https://github.com/jonasmalacofilho/liquidctl/commit/e1cdcb686e50231e425f0121f880289420510c8d
Upvotes: 1