From: Wander L. C. <wan...@gm...> - 2012-05-29 15:30:01
|
2012/5/29 Prince Arnaud RAMAHEFA-ANDRY <pri...@gm...>: > Hello, > > I've make this test on PyUSB to recover the data sent of the microcontroller > : > >>import time >>import usb.util >>import usb.backend >>import os >>import sys >>from usb import * >>import ctypes >>from ctypes import c_ubyte > >>import time > > >>ep_write=0x01 >>ep_read = 0x81 > > >># find our device >>dev = usb.core.find(idVendor=0x04D8, idProduct=0x0204) > >># 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() > >>d1 = time.time() > >>while i<10000: >> dev.write(ep_write, [0], 0, 18) >> data = dev.read(ep_read, 64, 0, 18) >> i = i+1 > >>d2 = time.time() >>print d2-d1 > > and I have : > >pythonw -u "py_libusb.py" > 20.8320000172 >>Exit code: 0 > try something like this: ep_write = usb.util.find(cfg[0,0], bEndpointAddress = 0x01) ep_read = usb.util.find(cfg[0,0], bEndpointAddress = 0x81) while i<500: ep_write.write([0], 18) data = ep_read.read(1280, 18) i = i+1 -- Best Regards, Wander Lairson Costa |