On 8/27/2016 3:35 PM, Joe wrote:
Hi,

I'm using Python 3.5.1 with PyUSB 1.0 under Win 10 (64). We try to read
the USB output of a DMM 'UT61B'.

import usb.core
import usb.util
import usb.backend.libusb1

def Gosub():
     dev = usb.core.find(idVendor=0x1a86, idProduct=0xe008) # Digital
Multimeter UT61B
     if dev == None:
         print ('Multimeter not found')
     else:
         print ('Multimeter was found')
         dev.set_configuration()
         cfg = dev.get_active_configuration()
         intf = cfg[(0,0)]
         ep = usb.util.find_descriptor(
             intf,
             custom_match = \
             lambda e: \
                usb.util.endpoint_direction(e.bEndpointAddress) == \
                usb.util.ENDPOINT_IN)
         if ep == None:
             print ('ep is None')
         else:
             s = ep.read(64, 500)
             print ('Len s: ' + len(s))

print ('Starting')
Gosub()
print ('Ready.-')

Result:

I presume you saw
Starting
Multimeter was found

File "d:\work-d\PythonProgs\ut61b.py", line 27, in <module>
   Gosub()
File "d:\work-d\PythonProgs\ut61b.py", line 23, in Gosub
   s = ep.read(64, 500)
File "D:\Python3\Lib\site-packages\usb\core.py", line 402, in read
   return self.device.read(self, size_or_buffer, timeout)
File "D:\Python3\Lib\site-packages\usb\core.py", line 988, in read
   self.__get_timeout(timeout))
File "D:\Python3\Lib\site-packages\usb\backend\libusb1.py", line 851, in
intr_read
   timeout)
File "D:\Python3\Lib\site-packages\usb\backend\libusb1.py", line 936, in
__read
   _check(retval)
File "D:\Python3\Lib\site-packages\usb\backend\libusb1.py", line 595, in
_check
   raise USBError(_strerror(ret), ret, _libusb_errno[ret])

usb.core.USBError: [Errno 10060] Operation timed out

What's wrong? How to fix?

Read (again?) the doc for the interface for the device. Because reading timed out, I suspect that it is waiting for a command for it to send something.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to