Op 12/27/2020 om 4:47 PM schreef James Richters via fpc-pascal:
I'm trying to figure out how to read a packet of HEX Bytes of an unknown
length that have no specific termination character over a serial port as
efficiently as practical.
The packet ends when there is just no more data to read.
I have something that is working that I wrote using SerRead from the Serial
unit in FPC, and it works at 9600bps,
but the method I am using will not work well at anything higher unless I can
figure out how to a very accurate very short delay.
At 9600, I need a delay just a little less than 1ms, so I use Sleep(1) for
my delay, but since 1ms is the minimum for sleep, and sleep
itself is not really that accurate, I am doing a lot more delay than I need
to in order to make sure it works.
You don't mention OS, but for Windows no sleep should not be necessary,
and is unnecessarily delaying.
Look at delphi tcomport which has a waitforevent based solution.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal