[fpc-pascal] Using Serial in a TCP/RS232 gateway, how to set buffer sizes?

Bo Berglund bo.berglund at gmail.com
Thu Sep 7 13:41:52 CEST 2017


On Thu, 7 Sep 2017 01:54:18 +0200, José Mejuto
<joshyfun at gmail.com> wrote:

>El 06/09/2017 a las 21:22, Bo Berglund escribió:
>>            Inc(RxTcp, Length(Buf));
>>            SerWrite(FComH, Buf[0], Length(Buf));
>>            Inc(TxSer, Length(Buf));
>> Where could I be losing incoming serial data?
>
>Hello,
>
>Where do you check that "Length(Buf)" has been sent ?

Well as you can see I don't.
However, I have not had any problems *receiving* data from the remote
server (this is where the SerWrite would be used to send it into my
Win7 program).
What I see is losing data when sending to the server, i.e. not all
bytes on the wire from the Win7 program are actually received by my
relaying code:

    SetLength(Buf, BufLen);
    LenRd := SerRead(FComH, Buf[0], BufLen);

Here data are arriving but some are lost, so the total number of bytes
relayed are too few.
THey are not lost on the TCP/IP outgoing side because I am counting
and showing the number of received bytes and this counter does not
ever go above 1000000, it stops somewhere at 970000 or so.

>if SerWrite(FComH, Buf[0], Length(Buf))<>Length(Buf) then Raise 
>Exception.Create("KBOOM");


-- 
Bo Berglund
Developer in Sweden




More information about the fpc-pascal mailing list