rene-aguirre / pywinusb

USB / HID windows helper library
BSD 3-Clause "New" or "Revised" License
203 stars 62 forks source link

Data reading! #80

Open fabio-ric-silva opened 9 months ago

fabio-ric-silva commented 9 months ago

Could someone help me with a simple example of reading 64 bytes?

On the examples, there is no kind example! Just writing!

jrowberg commented 9 months ago

Normally, you can't read on demand at the USB transport layer; it would be inefficient to transfer data in this way. At best, you would design your peripheral USB device to accept a written command and then push data back in response using a raw HID report or similar.

Along those lines, the raw_data.py example is probably the closest to what you want to see. This lets your PC-side app listen for new data coming from the peripheral device, and then the device just pushes whatever data it wants to whenever it's available:

https://github.com/rene-aguirre/pywinusb/blob/master/examples/raw_data.py