Dear ladies and gents, evening.
I have had partial success in interfacing an 8-bit microcontroller with a PC
running windows 10,Python and PyUsb.
I am a firmware specialist, i.e. not particularly proficient in Python, I am
new to PyUSB.
The problem is that my python program fails periodically with the following
error.
raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [_usb_reap_async] reaping
request failed, win error: The I/O operation has been aborted because of
either a thread exit or an application request.\r\n\n'
Is this error known? If so is there a "fix" and "What is it?"
Any assistance would be gratefully received, as this is an annoying problem
that I desperately need help to fix.
Many thanks
Greg
PS Code and output presented below.
#!/usr/bin/python
import usb.core
import usb.util
import time
# find our device
dev = usb.core.find(idVendor=0x04d8, idProduct=0x01a5)
# was it found?
if dev is None:
raise ValueError('Device not found %s')
print (dev)
dev.set_configuration()
cfg=dev[0]
intf=cfg[(0,0)]
ep=intf[0]
#print("print ep")
#print(ep)
#print("print cfg")
#print(cfg)
#print("print intf")
#print(intf)
out_ep_address = ep.bEndpointAddress
print ("ep.bEndpointAddress = %s" %out_ep_address)
#print(out_ep_address)
while True:
dev.write(0x01, [0x81, 0x08, 0x08,0x03,0x04,0x05,0x06,0x07])
time.sleep(0.1) # Sample (0.1)s == 1ms
test = dev.read(0x81, 8)
print (test)
C:\Users\User\AppData\Local\Programs\Python\Python36-32\python.exe
"C:/Users/User/Dropbox (Personal)/PyUSB/PyPIC 1.py"
DEVICE ID 04d8:01a5 on Bus 000 Address 001 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x200 USB 2.0
bDeviceClass : 0x0 Specified at interface
bDeviceSubClass : 0x0
bDeviceProtocol : 0x0
bMaxPacketSize0 : 0x8 (8 bytes)
idVendor : 0x04d8
idProduct : 0x01a5
bcdDevice : 0x1 Device 0.01
iManufacturer : 0x1 DIY Devices
iProduct : 0x2 16F1455 Generic HID Device
iSerialNumber : 0x0
bNumConfigurations : 0x1
CONFIGURATION 1: 100 mA ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0x29 (41 bytes)
bNumInterfaces : 0x1
bConfigurationValue : 0x1
iConfiguration : 0x0
bmAttributes : 0xa0 Bus Powered, Remote Wakeup
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 0x81: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x8 (8 bytes)
bInterval : 0x1
ENDPOINT 0x1: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x1 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x8 (8 bytes)
bInterval : 0x1
ep.bEndpointAddress = 129
array('B', [128, 0, 1, 1, 5, 6, 7, 8])
array('B', [128, 0, 0, 2, 6, 7, 8, 9])
array('B', [128, 0, 1, 3, 7, 8, 9, 10])
array('B', [128, 0, 0, 4, 8, 9, 10, 11])
array('B', [128, 0, 1, 5, 9, 10, 11, 12])
array('B', [128, 0, 0, 6, 10, 11, 12, 13])
array('B', [128, 0, 1, 7, 11, 12, 13, 14])
array('B', [128, 0, 0, 8, 12, 13, 14, 15])
array('B', [128, 0, 1, 9, 13, 14, 15, 16])
Traceback (most recent call last):
File "C:/Users/User/Dropbox (Personal)/PyUSB/PyPIC 1.py", line 48, in
<module>
test = dev.read(0x81, 8)
File
"C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\u
sb\core.py", line 988, in read
self.__get_timeout(timeout))
File
"C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\u
sb\backend\libusb0.py", line 560, in intr_read
timeout)
File
"C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\u
sb\backend\libusb0.py", line 627, in __read
timeout
File
"C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\u
sb\backend\libusb0.py", line 431, in _check
raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [_usb_reap_async] reaping
request failed, win error: The I/O operation has been aborted because of
either a thread exit or an application request.\r\n\n'
Process finished with exit code 1
Regards
Greg
Dr Greg Horler
07764 191965
------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users