On Mon, 8 Jun 2020, Christo Crause via fpc-devel wrote:

On Sun, Jun 7, 2020 at 11:54 PM Michael Van Canneyt <mich...@freepascal.org>
wrote:


On Sun, 7 Jun 2020, Christo Crause via fpc-devel wrote:

I want to change the _haltproc for freertos ESP controllers to use normal
write/writeln functionality to send information to standard output.  On
these targets the output is typically buffered serial provided by the OS.
Text output written just prior to setting the cpu to sleep doesn't get
sent, hence a flush is needed to complete data transmission before
putting
the cpu to sleep.  Looking at consoleio.OpenIO there doesn't seem to be a
convenient way to provide a flush helper function. Also the RTL Flush
procedure calls InOutFunc and not FlushFunc.

What is the proper way to hook a flush helper function into the existing
RTL infrastructure?

Simply do this in InoutFunc ?

Michael.


Thanks for your response Michael.  Using InOutFunc to also flush the output
buffer will work, but that seems inefficient, since the flush needs to wait
until the transmit buffer is empty (at slow UART speeds this could
potentially take several ms to complete).   Is there a specific reason why
the RTL Flush procedure does not call the FlushFunc method?

I checked; That code is so old, no idea.

From what I can see the flush code could be changed to

if Assigned((TextRec(t).FlushFunc) then
  FileFunc(TextRec(t).FlushFunc)(TextRec(t))
else
  FileFunc(TextRec(t).InOutFunc)(TextRec(t));

But keep in mind that the InoutFunc() is only called when actually writing
data, meaning: when the internal text buffer is full or on a terminal with
every writeln(), so I don't think it is inefficient. Writeln() will do a
flush. Whether this happens in .InOutFunc or .FlushFunc is largely irrelevant.

Michael.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to