Question

Using libusb under Windows (where poll/select support is not quite there), is there a way to check for pending bytes on some USB endpoint, i.e. to check whether a following read will succeed (and read one or more bytes)?

Was it helpful?

Solution

I worked around the problem by implementing a ring buffer with already read bytes; checking for pending bytes looks in the ring buffer and (if it is empty) performs a non-blocking read on the endpoint (writing into the ring buffer if there's anything), and reading must use the ring buffer indirection instead of reading directly from the endpoint. This works for me, but is not very elegant.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top