[fpc-devel] ConsoleIO and flushing buffered output

Michael Van Canneyt michael at freepascal.org
Tue Jun 9 00:03:33 CEST 2020



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

> Thank you Michael and Jonas for your help and suggestions.  I think I ended
> up merging your suggestions, which does work for my corner case.  If anyone
> is interested this change can be viewed here:
> https://github.com/ccrause/freepascal/commit/b28ab72ed07f11677493d5d0e37ee451d2313323
>
> I must admit that I was thoroughly confused by the apparent lack of
> semantic difference in use between InOutFunc and FlushFunc of TextRec
> structure.

Could you please submit a patch with this modification to the bugtracker ?

We don't as a rule follow up on such things in github.

Michael.

>
> Best wishes,
> Christo
>
> On Mon, Jun 8, 2020 at 9:58 PM Jonas Maebe <jonas at freepascal.org> wrote:
>
>> On 07/06/2020 19:16, 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?
>>
>> The flushfunc is called from fpc_write_end and fpc_writeln_end. Those
>> helpers are automatically called after all of the individual write
>> operations from a write(ln) statement have been processed. So if you
>> implement/assign flushfunc and make it call your OS flush function, it
>> should work fine.
>>
>>
>> Jonas
>> _______________________________________________
>> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
>> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>>
>


More information about the fpc-devel mailing list