My concern was that I could not read and write at the exact same time.... 

-----Original Message-----
From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of Stefan 
V. Pantazi
Sent: Sunday, August 18, 2019 9:32 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] USB Human Interface Devices

>> My guess is that it would be better to leave the time sensitive read 
>> thread to do the fast reads and immediate calculations and leave 
>> writing to the device screen in a separate thread (even main thread), 
>> with a lower update frequency!
> 
> Yes, that was what I was attempting to describe.. but I can't write to the 
> usb device if the read thread happens to be in the middle of a read... so how 
> do I pause the read thread at the correct time so it's not partially in the 
> middle of reading a packet, and I can't read again until I'm done writing.  I 
> figure I can just check for some period of time of idle handwheel input 
> before I stop the read thread and do the write then start the read thread 
> again, because only the handwheel produces such a large stream of data.. but 
> still I’m not sure how to make sure I stop it at the correct time.

I do not get why should you stop the read thread, when that is the actual 
advantage of having multiple threads. While the read thread is busily reading 
input in a buffer/queue/what have you, you are free within limits) to do 
whatever you need to do (e.g., output to LCD display, do calculations) in the 
other threads, including the main thread, after which, you can get back to 
consuming and processing the (hopefully only slightly larger now) data from the 
read thread buffer/queue. After you figured writing to the LCD screen you could 
try writing random data to it while reading and processing handwheel and button 
input *at the same time*. Hope this makes sense.



_______________________________________________________
_______________________________________________
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

Reply via email to