[fpc-pascal] Using Serial in a TCP/RS232 gateway, how to set buffer sizes?
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Wed Sep 6 20:58:57 CEST 2017
On 06/09/17 18:45, Bo Berglund wrote:
> I have created a simple application which relays data from anapplication I am debugging in Windows7 to/from a remotely locatedembedded data system.I use the built-in fpc Serial unit to handle the serial data and anIndy10 TIdTcpClient for the network part.Data coming in on the serial port are mirrored out to the remote TCPserver and data returned from that server are mirrored to the serialport.The Windows application only uses RS232 for this type ofcommunication.At the remote location I have a Raspberry Pi uint where I haveinstalled and configured ser2net to do the same job in the remotelocation.
> My relaying application displays the number of bytes received andtransmitted on the interfaces so I can see what is going on.
> This scheme has worked fine for most commands and data transfers Ihave checked, but now I have run against a brick wall...
> There is a pair of commands designed to read and write a large sectionof the system CMOS RAM memory (where the data file system resides).When I try to write a 1 Mbytes big buffer the byte count in my relayerdoes not reach the correct number. The Windows application I amdebugging sends all of the bytes out the serial port (I have loggedthis), but the relayer seems to lose some data and therefore thetransfer fails. The binary protocol specifies at the start how manybytes are to be transferred (0x0FF000 or 1044486 decimal), then itsends the data followed by a two-byte checksum. The data system shallrespond with NAK or ACK depending on the outcome of the checksumverification.The problem is that when the Windows app is done sending the datasystem is still missing many kilobytes....So no ACK is returned, it is still in receive mode.
> Now I am looking at the Serial unit in order to figure out how buffersizes influence the performance. Apparently both Tx and Rx buffers areset (hardcoded) to 2048, which feels like a bit low to me.
> Is there some hidden property that makes it possible to increase thisvalue?What is the maximum size one can set it too?
Not that I was responsible for. Refer to the Windows API for any limits.
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