I've written a usb device driver and a program that sends and receives data over the bulk pipe. The read function sometimes returns -1 when I'm reading an unknown amount of data. However, using a usb tracker I can see that the correct data is being sent.

The error only occurs sometimes. I expect that the read function is told to read more data that it receives it would fail and return -1, however if this was the case then every read call would fail.

Thanks in advance for any help.