Thank you for adding the timeout! That will work for this project, but I may look into threads in my console program, I could simplify a lot of things where I am maintaining a buffer while something else is being fed by the buffer that would probably be a lot easier if I had threads.
I've got the read working and have decoded all the buttons and switches on my device, but I still can't write to the display... well not on purpose.. something wrote a bunch of garbage to it at some point, which it is remembering. The problem I am going to have with the LCD is that this device is not the exact one that I have sample code for.. when I decoded all my buttons and switches I realized that I was getting NOTHING like the sample. The sample is for an HB04 and this is a WHB04B, the W is just for wireless.. but the B is a completely different thing.. unfortunately I can't seem to even buy the original one without the B without waiting for a month for it to get here from China... I ordered one today.. but maybe before it gets here I'll figure out some way to just blast data to this one until something happens on the screen, and then I can figure it out. Thanks for the help with all this!! James -----Original Message----- From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of Stefan V. Pantazi Sent: Friday, August 16, 2019 1:30 PM To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] USB Human Interface Devices On 8/16/19 11:11 AM, James Richters wrote: >>> Remember that interrupt reads are blocking so the way to deal with >>> them is to put them away from the main thread, in their own thread. >>> The moment something is available from the device, then the main >>> thread of your application is signaled to read a buffer with the >>> device report data. So, I can see some thread programming in your >>> future or, I see I did not finish my sentence. What I had in mind is that you could use a library that already implements (using a thread I assume) a call with a timeout. I checked and it looks like the original libusb call that I used did have a timeout parameter that I hardcoded to 0 (infinite timeout). libusb report a timeout as an error code. That did not sit well with me and I preferred to use threads instead of time-out mechanism. > Is there another way to do a read that has a timeout? yes, it took only a few minutes to add the time-out parameter to the libusbhid_interrupt_read call. Have a look at the github repository for the updated version. > > Can I even do threads in a console program? Sure you can, here is one of the simplest example you can start with should you ever need to have multiple threads in your programs. https://github.com/graemeg/freepascal/blob/master/packages/fcl-base/examples/threads.pp -- _______________________________________________________ _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal