PyUSB raises timeout after reading non-zero amount of data from bulk endpoint

libusb_bulk_transfer may return both a non-zero transferred size and
also an errno indicating timeout.

In such cases, pyusb raises an exception, and there's no way for my
application to retrieved the data that was read from USB. As a result,
the data is lost. Subsequent reads will not return it.

See libusb-1.0 docs:
http://libusb.sourceforge.net/api-1.0/group__syncio.html#gab8ae853ab492c22d707241dc26c8a805
...check transferred when dealing with a timeout error code. libusb
may have to split your transfer into a number of chunks to satisfy
underlying O/S requirements, meaning that the timeout may expire after
the first few chunks have completed. libusb is careful not to lose any
data that may have been transferred; do not assume that timeout
conditions indicate a complete lack of I/O.

You can pull my my patched version here:
git://github.com/braiden/pyusb.git (up-to-date with your master
branch)

I've been using this for a couple weeks without issue. Patch is pretty
trivial. in libusb10, don't call _check unless zero bytes transferred.
I've only seen the issue while reading from device, but I assume it
possible on write too.

I think the issue applies to libusb01 too.

I can pretty reliably reproduce issue. Let me know if I can provide
more detail or help verify fix.

Regards,


[sorry if i posted twice, i think the spam filters blocked first try]

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to