2012/5/29 Prince Arnaud RAMAHEFA-ANDRY <prink...@gmail.com>:
> 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

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to