Le 02/09/2016 à 11:33, Joe a écrit :
Am 02.09.2016 um 11:22 schrieb Xiaofan Chen:
On Thu, Sep 1, 2016 at 10:30 PM, Joe <t...@joepgen.com> wrote:
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):
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?
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


Thank you - Joe


------------------------------------------------------------------------------
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users
.



--
*Nicolas PINAULT
R&D electronics engineer
*** nico...@aaton.com <mailto:nico...@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

------------------------------------------------------------------------------
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to