Hello,
I am relatively new to both Python and PyUSB, so I apologize in advance if
I've missed something painfully obvious.
I am attempting to interface with a Yokogawa WT310HC digital power meter
that as far as I can tell, accepts ASCII text codes transferred over USB.
I am running in Python 2.7.3 on Windows 2000.
I am getting an error that I am having trouble interpreting. I do notice
that the first command issued after the device is first plugged in will
pass, but the second will not. And if I try to rerun the program without
unplugging and plugging in the device, the first command issued will
produce the error.
The error:
> C:\Python27>python.exe scripts\WT310-pyusb-test.py
> Traceback (most recent call last):
> File "scripts\WT310-pyusb-test.py", line 44, in <module>
> ep.write("COMMUNICATE:REMOTE ON\n")
> File "C:\Python27\lib\site-packages\usb\core.py", line 287, in write
> return self.device.write(self.bEndpointAddress, data, self.interface,
timeout)
> File "C:\Python27\lib\site-packages\usb\core.py", line 631, in write
> self.__get_timeout(timeout)
> File "C:\Python27\lib\site-packages\usb\backend\libusb0.py", line 478,
in bulk_write
> data, timeout)
> File "C:\Python27\lib\site-packages\usb\backend\libusb0.py", line 560,
in __write
> timeout
> File "C:\Python27\lib\site-packages\usb\backend\libusb0.py", line 388,
in _check
> raise USBError(errmsg, ret)
> usb.core.USBError: [Errno None] libusb0-dll:err [_usb_reap_async] reaping
request failed,
> win error: Data error (cyclic redundancy check).
------
My code is:
> from __future__ import print_function
> import usb.core
> import usb.util
> import csv # learn how to use this
> import os
> from colorama import init
>
> # initialize colorama
> init()
>
> # Find our device
> # dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001) # example
> dev = usb.core.find(idVendor=0x0B21, idProduct=0x0025)
>
> # Was it found?
> if dev is None:
> raise ValueError('Device not found')
>
> # Set the active configuration. With no arguments, the first
> # configuration will be the active one
>
> dev.set_configuration()
>
> # Get an endpoint instance
> cfg = dev.get_active_configuration()
> interface_number = cfg[(0,0)].bInterfaceNumber
> alternate_setting = usb.control.get_interface(dev, interface_number)
> intf = usb.util.find_descriptor(
> cfg, bInterfaceNumber = interface_number,
> bAlternateSetting = alternate_setting
> )
>
> ep = usb.util.find_descriptor(
> intf,
> # match the first OUT endpoint
> custom_match = \
> lambda e: \
> usb.util.endpoint_direction(e.
bEndpointAddress) == \
> usb.util.ENDPOINT_OUT
> )
>
> assert ep is not None
>
> ep.write("COMMUNICATE:REMOTE ON\n")
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users