Am 28.08.2016 um 00:45 schrieb Terry Reedy:
> 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.
>
Yes, I saw this:
Starting
Multimeter was found
The UT61B has two interfaces, a RS232C interface and this usb interface.
The RS232 interface works well with PySerial. It continously transmits 2
.. 3 Pakets per second with 14 Bytes each. This happens unsolicited
without any command as long as the RS232C/USB button on the DMM is active.
So I assumed the USB interface also doesn't need any command and also
transmit this stream of 2 to 3 Pakets per second. But unfortunately I
don't have any doc for the USB interface for this device.
To the accompanying software of the UT61B there is a ready windos app
which shows and logs the output of the UT61B. This app can be switched
between RS232C and USB; both work.
I asked the manufacturer (Uni-T in Shenzen) for additional info and are
now waiting for an answer.
Assumed the USB interface sends this 2 to 3 pakets per second
unsolicited - should the code shown work? Is this ok:
>> lambda e: \
>> usb.util.endpoint_direction(e.bEndpointAddress) == \
>> usb.util.ENDPOINT_IN)
I am in doubt: Is usb.util.ENDPOINT_IN really correct?
Thanx - Joe
--
https://mail.python.org/mailman/listinfo/python-list