Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Isochronous Read/Write with PyUSB

Tags:

libusb

pyusb

PyUSB 1.0 claims to now support isochronous transfers if the underlying backend supports it. I've figured out how to select the libusb1.0 backend which supports isochronous transfer, but I'm not sure how to actually implement reads and writes. I've searched the Internets and cannot find an example using PyUSB. Help?

like image 945
baltimore_cg Avatar asked Dec 13 '25 02:12

baltimore_cg


1 Answers

Ok, so I'm answering my own question because I found the solution. It turns out PyUSB will automatically choose the correct read/write method depending on the type of endpoint being operated on. From core.py in the definition for 'write' see:

fn_map = {
            util.ENDPOINT_TYPE_BULK:backend.bulk_write,
            util.ENDPOINT_TYPE_INTR:backend.intr_write,
            util.ENDPOINT_TYPE_ISO:backend.iso_write
        }

And similarly in the definition for 'read' see:

fn_map = {
            util.ENDPOINT_TYPE_BULK:backend.bulk_read,
            util.ENDPOINT_TYPE_INTR:backend.intr_read,
            util.ENDPOINT_TYPE_ISO:backend.iso_read
        }

So really, all that needs to be done is call {device}.read() or {device}.write() and the code will handle assigning the appropriate operation.

I was going to delete my question rather than answer it, but since isochronous transfer is relatively new to PyUSB I'm hoping this will help other folks not waste a full day to discover what I just did :)

like image 109
baltimore_cg Avatar answered Dec 16 '25 00:12

baltimore_cg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!