vpelletier / python-libusb1

Python ctype-based wrapper around libusb1
GNU Lesser General Public License v2.1
174 stars 67 forks source link

I/O Problem #9

Closed mellymello closed 9 years ago

mellymello commented 9 years ago

Hello,

I'm sorry if it's not the good place to post this but i'm new in github and i don't know where I should ask.

I'm using your tool to build a fuzzer over USB. I succeed to write data with the synchronous fonctions (bulkWrite) but I failed to read with the "bulkRead" fontion (Nothing is received). I want to try to use the asynchronous fonctions to see if it solves the problem but I have some problems to understand how I can use the snippet code you gave.

Do you have a full example of an asynchronous communication or a link to another project which use the asynchronous fonctions ?

vpelletier commented 9 years ago

Hello,

Sorry, for some reason I didn't notice this report/question. I'm not sure what you are meaning by "fuzzer": Trying to pump random data to a USB device to test it, or a fuzzer for something else which just happens to be controlled over USB ? For the former, I guess USB is complex enough that just random pokes would be inefficient. Devices may not produce any data on an endpoint until configured enough on another endpoint. As to the async API, I think you should stick with sync API until you have something working, and only then think about performance (which is just what async API is about, not really functionality (well, isochronous transfers are only available via async API, but precisely because of latency constraints AFAIK).

As for a working example with >35MB/s performance using async API (but not overly complicated), there is my userland driver for the International Test Instruments 1480A USB device (which happens to be a USB protocol analyser, but you shouldn't need to worry about this to understand the code).

Basic principle of async API usage:

mellymello commented 9 years ago

Thanks for your help.

The fuzzer is for MTP devices.

I'll follow your advice and I'll stick with the sync API until it works well. I don't need performance right now anyway.