[fpc-pascal] Using Serial in a TCP/RS232 gateway, how to set buffer sizes?
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Thu Sep 7 12:42:59 CEST 2017
On 06/09/17 19:30, Bo Berglund wrote:
> Where could I be losing incoming serial data?
FTcpComm.IOHandler.ReadBytes(Buf, -1, false);
..
SerWrite(FComH, Buf[0], Length(Buf));
SerWrite() returns the actual number of bytes it's written, which could
be anywhere from the number passed as the parameter down to zero (if
hardware handshaking's being used at a lower level). An intermediate
value would indicate that a buffer's full somewhere, and that you should
adjust your source address and length and have another shot.
TCP is a stream protocol and you can't make any assumptions about the
amount of data you get in one call. It's not reasonable to assume that
buffers for serial comms are limitless, 2K is entirely reasonable to
support most serial comms protocols or an 80x25 screen.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal
mailing list