[fpc-pascal] USB Human Interface Devices
Stefan V. Pantazi
svpantazi at gmail.com
Fri Aug 23 01:59:03 CEST 2019
> I suspect when the timeout time has been reached interrupt_read is calling libusb_cancel_transfer to stop waiting for the transfer. It seems likely that what's happening is that once in a while it tries to cancel the transfer, but before libusb_cancel_transfer has a chance to cancel it, some data comes in real quick and now it's done and there is nothing to cancel.. that would explain why it happens only intermittently.. it just has to happen that some data comes in at almost the exact same time as the timeout time.
>
> Since this error is generated by: LIBUSB_ERROR_NOT_FOUND if the transfer is not in progress, already complete, or already cancelled. And nothing else could have cancelled it except the timeout, and the timeout would not have been issued if the transfer was in progress.. that leaves that the transfer popped in real quick and completed before the timeout was done calling for a cancel transfer.
Here is something you can try immediately. How about setting the timeout
on interrupt read to some ridiculously larger value, say 20 seconds to
see if the error happens less frequently. Of course, when you close the
program you may have to wait up to 20 seconds for the read thread to finish.
More information about the fpc-pascal
mailing list