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

2017-09-12 Thread Michael Schnell
On 06.09.2017 20:35, Bo Berglund wrote: ... (i.e. appropriately small packets. counting packet number. ACK block containing the packet number it answers to, timeout, retransmit, ...) Not to forget: save detection of block start and block end (and hence introducing a decent

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

2017-09-12 Thread Michael Schnell
On 06.09.2017 20:35, Bo Berglund wrote: The problem is that when the Windows app is done sending the data system is still missing many kilobytes So no ACK is returned, it is still in receive mode. On serial lines bits and bytes always can get lost or be distorted, independent from OS,

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

2017-09-08 Thread wkitty42
On 09/08/2017 04:34 AM, Bo Berglund wrote: Next I unchecked the checkbox before doing the long transfer, and lo-and-behold(!) now there are no losses anymore! So the action of writing text to the listbox in the LogHex function was actually causing the application to lose incoming serial data!

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

2017-09-08 Thread Bo Berglund
On Fri, 8 Sep 2017 13:06:16 +0100, el es wrote: > >I would decouple the log display from the serial handling routines - >by delegating the serial task to a thread, only display of log is handled in >the main thread (this is true whether your application is cli-only or gui -

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

2017-09-08 Thread el es
On 08/09/17 09:34, Bo Berglund wrote: > 6) Then I rebuilt my application, but I have no idea if this actually > caused any buffer change. I know too little about the inner workings > of the Lazarus/FPC system... > > So it might still use the tiny 2K buffer??? > > I would decouple the log

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

2017-09-08 Thread Bo Berglund
On Thu, 07 Sep 2017 13:48:27 +0200, Bo Berglund wrote: >I think I will have to create a bogus image file where I have a >regular pattern of bytes so I can see when the hickups occur in the >log. In a normal memory file most of the data is zero, so there are >long stretches

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

2017-09-07 Thread Marc Santhoff
On Do, 2017-09-07 at 13:32 +0200, Bo Berglund wrote: > On Wed, 06 Sep 2017 23:21:17 +0200, Marc Santhoff > wrote: > > >Could that be some sort of timeout? > > > >You're setting > > > > FTcpComm.ReadTimeout := 30; > > > >but I have no idea what order of magnitude this 30 is.

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

2017-09-07 Thread Bo Berglund
On Thu, 7 Sep 2017 10:42:59 +, Mark Morgan Lloyd wrote: >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).

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

2017-09-07 Thread Bo Berglund
On Thu, 7 Sep 2017 01:54:18 +0200, José Mejuto 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

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

2017-09-07 Thread Bo Berglund
On Wed, 06 Sep 2017 23:21:17 +0200, Marc Santhoff wrote: >Could that be some sort of timeout? > >You're setting > > FTcpComm.ReadTimeout := 30; > >but I have no idea what order of magnitude this 30 is. Maybe streching >the timeout a little bit can help? > >I had several cases

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

2017-09-07 Thread Mark Morgan Lloyd
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

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

2017-09-07 Thread Mark Morgan Lloyd
On 06/09/17 21:15, Bo Berglund wrote: I could also create another test program, a serial sniffer that couldbe set up to just log whatever appears on the serial lines. I need a3-way cable for that of course. I'd also suggest that that sort of thing works better with on-board or at least

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

2017-09-06 Thread Paul Breneman
On 09/06/2017 05:21 PM, Marc Santhoff wrote: On Mi, 2017-09-06 at 23:06 +0200, Bo Berglund wrote: On Wed, 06 Sep 2017 22:52:12 +0200, Bo Berglund wrote: I have now added extra binary logging to the relaying program only to find that the data received and processed are

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

2017-09-06 Thread José Mejuto
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 ? if

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

2017-09-06 Thread Marc Santhoff
On Mi, 2017-09-06 at 23:06 +0200, Bo Berglund wrote: > On Wed, 06 Sep 2017 22:52:12 +0200, Bo Berglund > wrote: > > >I have now added extra binary logging to the relaying program only to > >find that the data received and processed are missing about 50 k of > >the 1M

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

2017-09-06 Thread Bo Berglund
On Wed, 06 Sep 2017 22:52:12 +0200, Bo Berglund wrote: >I have now added extra binary logging to the relaying program only to >find that the data received and processed are missing about 50 k of >the 1M transmission. >Next I will edit serial.pp and up the buffers from 2K

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

2017-09-06 Thread Bo Berglund
On Wed, 06 Sep 2017 22:52:12 +0200, Bo Berglund wrote: >Next I will edit serial.pp and up the buffers from 2K to 60K or so. Question: If I edit the content of serial.pp (the one that is brought up by right clicking and "Find declaration") such that it looks like this:

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

2017-09-06 Thread Bo Berglund
On Wed, 06 Sep 2017 22:27:49 +0200, Marc Santhoff wrote: >On Mi, 2017-09-06 at 21:22 +0200, Bo Berglund wrote: >> Where could I be losing incoming serial data? > >Only for completeness: > >Can you rule out problems reagrding the hardware side? Mabe there are >some weak line

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

2017-09-06 Thread Marc Santhoff
On Mi, 2017-09-06 at 21:22 +0200, Bo Berglund wrote: > Where could I be losing incoming serial data? Only for completeness: Can you rule out problems reagrding the hardware side? Mabe there are some weak line drivers or a faulty cable involved? Worth checking, at least. HTH anyhow, Marc

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

2017-09-06 Thread Mark Morgan Lloyd
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

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

2017-09-06 Thread Bo Berglund
I have created a simple application which relays data from an application I am debugging in Windows7 to/from a remotely located embedded data system. I use the built-in fpc Serial unit to handle the serial data and an Indy10 TIdTcpClient for the network part. Data coming in on the serial port are