[fpc-pascal] USB Human Interface Devices

Stefan V. Pantazi svpantazi at gmail.com
Thu Aug 22 20:59:07 CEST 2019


I added libusbhid_test_with_thread.pp to github. In that test you will 
notice I also attempted to test sharing across threads a data structure 
with (hypothetical) pen positions, using critical sections. Seems to 
work ok, but more testing is needed to make sure there are no problems.

The way I see this working in your particular context, would be that the 
shared data structure would be written to/updated in the read thread and 
read less frequently in the main thread in order to update the display.

On 8/22/19 11:21 AM, James Richters wrote:
> That sounds like exactly like what I was trying to do..  would you mind sending me your graphic tablet test?  Maybe I can learn something from seeing how you do things.
> 
> clear halt failed
> it seems to work fine.. but I always get that error.. not sure where that is coming from, or if that might be related to these other issues.

That error message is fine. It is an attempt to revive an USB endpoint 
that has stalled, just in case. If your devices are behaving, then you 
may even skip that attempt in the open function call.

> 
> It seems no matter what I do... even write out dummy data so I'm not even using the same variables I am reading at all.. I either get a fatal error on read, a fatal error on write, or occasional libusb: warning [handle_timeout] async cancel failed -5 errno=0 messages.

-5 is LIBUSB_ERROR_NOT_FOUND - this may give a clue

http://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga685eb7731f9a0593f75beb99727bbe54

As to why your transfers are being canceled, I have no idea. Anyway, 
keep in mind that I am using Linux and a completely different USB device 
- so libusb implementations, OS and device differences may play a role 
in how the programs behave.



More information about the fpc-pascal mailing list