Discussion:
[pyusb-users] Digital Multimeter Output
Joe
2016-09-01 14:30:39 UTC
Permalink
We use two DMMs UNI-T UT61B. They have two interfaces each, a RS232C
Interface and a USB interface.
The RS232C interfaces work well. Without any command before, the DMMs
continuously send 2 .. 3 packages of 14 Bytes per second. We get them
with a little Python 3.52 script, using PySerial. It's ok.

But the younger of our computers have no RS232C comports, and I don't
want to use virtual comports. So I try to use the USB interfaces of the
DMMs with PyUSB 1.0, but somethin is wrong with this test script (using
Win10 Version 1607, 64 bit):

import usb.util
import usb.backend.libusb1

def Gosub():
failures = 0
failuresmaximum = 48
dev = usb.core.find (idVendor = 0x1a86, idProduct = 0xe008) #
Multimeter UT61B
if dev == None:
print ('Multimeter UT61B not found')
else:
print ('Multimeter UT61B was found')
dev.set_configuration (1)
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 = None
while failures < failuresmaximum:
try:
s = ep.read (64, 50)
print ('Success. len (s): ' + len (s))
counter = 0
except:
failures += 1
print ('Failures: ' + str (failures))
if s == None:
print ('No data read')
else:
for ss in s:
print (str (ss)) # Not decoded; just to check:
something received?

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

I get this output:

Starting
Multimeter UT61B was found
Failures: 48
No data read
Ready.-

How to fix - any hint?
Regards - Joe
Xiaofan Chen
2016-09-02 09:22:02 UTC
Permalink
Post by Joe
We use two DMMs UNI-T UT61B. They have two interfaces each, a RS232C
Interface and a USB interface.
The RS232C interfaces work well. Without any command before, the DMMs
continuously send 2 .. 3 packages of 14 Bytes per second. We get them with a
little Python 3.52 script, using PySerial. It's ok.
But the younger of our computers have no RS232C comports, and I don't want
to use virtual comports. So I try to use the USB interfaces of the DMMs with
PyUSB 1.0, but somethin is wrong with this test script (using Win10 Version
You need to check what kind of USB protocol the USB interface uses.
Maybe it is also a USB Serial Port and you can use the PySerial. If it
is not a USB serial port and you do not know the communication protocol,
then you have to carry out reverse engineering.

Google seems to say that sigrok supports it. You can try ask there
for the protocol.
https://sigrok.org/wiki/UNI-T_UT61B
--
Xiaofan

------------------------------------------------------------------------------
Joe
2016-09-02 09:33:00 UTC
Permalink
Post by Xiaofan Chen
Post by Joe
We use two DMMs UNI-T UT61B. They have two interfaces each, a RS232C
Interface and a USB interface.
The RS232C interfaces work well. Without any command before, the DMMs
continuously send 2 .. 3 packages of 14 Bytes per second. We get them with a
little Python 3.52 script, using PySerial. It's ok.
But the younger of our computers have no RS232C comports, and I don't want
to use virtual comports. So I try to use the USB interfaces of the DMMs with
PyUSB 1.0, but somethin is wrong with this test script (using Win10 Version
You need to check what kind of USB protocol the USB interface uses.
Maybe it is also a USB Serial Port and you can use the PySerial. If it
is not a USB serial port and you do not know the communication protocol,
then you have to carry out reverse engineering.
Google seems to say that sigrok supports it. You can try ask there
for the protocol.
https://sigrok.org/wiki/UNI-T_UT61B
Thank you, Xiaofan, I'll look at sigrok.
In the mean time I tried another attempt:

import usb.util
import usb.backend.libusb1

def Gosub():
failures = 0
failuresmaximum = 48
dev = usb.core.find (idVendor = 0x1a86, idProduct = 0xe008) #
Multimeter UT61B
if dev == None:
print ('Multimeter UT61B not found')
else:
print ('Multimeter UT61B was found')
print ('dev:\n' + str (dev) + '\n')
dev.set_configuration ()
ep = dev [0] [0,0] [0]
if ep == None:
print ('ep is None')
else:
data = None
while failures < failuresmaximum:
try:
data = dev.read (ep.bEndpointAddress, ep.wMaxPackeSize)
print ('Success. len (date): ' + len (date))
except:
failures += 1
print ('Failures: ' + str (failures))
if data == None:
print ('No data read')
else:
for ss in data:
print (str (ss))

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

Output:

Starting
Multimeter UT61B was found
dev:
DEVICE ID 1a86:e008 on Bus 003 Address 003 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x100 USB 1.0
bDeviceClass : 0x0 Specified at interface
bDeviceSubClass : 0x0
bDeviceProtocol : 0x0
bMaxPacketSize0 : 0x8 (8 bytes)
idVendor : 0x1a86
idProduct : 0xe008
bcdDevice : 0x1200 Device 18.0
iManufacturer : 0x1 WCH.CN 
iProduct : 0x2 USB to Serial
iSerialNumber : 0x0
bNumConfigurations : 0x1
CONFIGURATION 1: 100 mA ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0x29 (41 bytes)
bNumInterfaces : 0x1
bConfigurationValue : 0x1
iConfiguration : 0x4 Error Accessing String
bmAttributes : 0x80 Bus Powered
bMaxPower : 0x32 (100 mA)
INTERFACE 0: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x0
ENDPOINT 0x82: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x82 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x8 (8 bytes)
bInterval : 0x5
ENDPOINT 0x2: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x2 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x8 (8 bytes)
bInterval : 0x5

Failures: 48
No data read
Ready.-

Does anybody see the mistake?

Thank you - Joe


------------------------------------------------------------------------------
Nicolas Pinault
2016-09-02 11:18:43 UTC
Permalink
Post by Joe
Post by Xiaofan Chen
Post by Joe
We use two DMMs UNI-T UT61B. They have two interfaces each, a RS232C
Interface and a USB interface.
The RS232C interfaces work well. Without any command before, the DMMs
continuously send 2 .. 3 packages of 14 Bytes per second. We get them with a
little Python 3.52 script, using PySerial. It's ok.
But the younger of our computers have no RS232C comports, and I don't want
to use virtual comports. So I try to use the USB interfaces of the DMMs with
PyUSB 1.0, but somethin is wrong with this test script (using Win10 Version
You need to check what kind of USB protocol the USB interface uses.
Maybe it is also a USB Serial Port and you can use the PySerial. If it
is not a USB serial port and you do not know the communication protocol,
then you have to carry out reverse engineering.
Google seems to say that sigrok supports it. You can try ask there
for the protocol.
https://sigrok.org/wiki/UNI-T_UT61B
Thank you, Xiaofan, I'll look at sigrok.
import usb.util
import usb.backend.libusb1
failures = 0
failuresmaximum = 48
dev = usb.core.find (idVendor = 0x1a86, idProduct = 0xe008) #
Multimeter UT61B
print ('Multimeter UT61B not found')
print ('Multimeter UT61B was found')
print ('dev:\n' + str (dev) + '\n')
dev.set_configuration ()
ep = dev [0] [0,0] [0]
print ('ep is None')
data = None
data = dev.read (ep.bEndpointAddress, ep.wMaxPackeSize)
print ('Success. len (date): ' + len (date))
failures += 1
print ('Failures: ' + str (failures))
print ('No data read')
print (str (ss))
print ('Starting')
Gosub ()
print ('Ready.-')
Starting
Multimeter UT61B was found
DEVICE ID 1a86:e008 on Bus 003 Address 003 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x100 USB 1.0
bDeviceClass : 0x0 Specified at interface
bDeviceSubClass : 0x0
bDeviceProtocol : 0x0
bMaxPacketSize0 : 0x8 (8 bytes)
idVendor : 0x1a86
idProduct : 0xe008
bcdDevice : 0x1200 Device 18.0
iManufacturer : 0x1 WCH.CN 
iProduct : 0x2 USB to Serial
iSerialNumber : 0x0
bNumConfigurations : 0x1
CONFIGURATION 1: 100 mA ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0x29 (41 bytes)
bNumInterfaces : 0x1
bConfigurationValue : 0x1
iConfiguration : 0x4 Error Accessing String
bmAttributes : 0x80 Bus Powered
bMaxPower : 0x32 (100 mA)
INTERFACE 0: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x0
ENDPOINT 0x82: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x82 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x8 (8 bytes)
bInterval : 0x5
ENDPOINT 0x2: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x2 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x8 (8 bytes)
bInterval : 0x5
Failures: 48
No data read
Ready.-
Does anybody see the mistake?
Your device is a HID device.
You can't use PyUSB with HID devices under Windows.
For HID devices I use this : https://pypi.python.org/pypi/hid/0.1.1

Nicolas
Post by Joe
Thank you - Joe
------------------------------------------------------------------------------
_______________________________________________
pyusb-users mailing list
https://lists.sourceforge.net/lists/listinfo/pyusb-users
.
--
*Nicolas PINAULT
R&D electronics engineer
*** ***@aaton.com <mailto:***@aaton.com>

*AATON-Digital*
38000 Grenoble - France
Tel +33 4 7642 9550

http://www.aaton.com
http://www.transvideo.eu
French Technologies for Film and Digital Cinematography

Follow us on Twitter
@Aaton_Digital
@Transvideo_HD

Like us on Facebook
https://www.facebook.com/AatonDigital
Loading...