[fpc-pascal] SerReadTimeout question

Christo Crause christo.crause at gmail.com
Mon Sep 19 17:45:22 CEST 2022


On Mon, Sep 19, 2022 at 7:51 AM Christo Crause <christo.crause at gmail.com>
wrote:

>
>
> On Mon, 19 Sep 2022, 03:18 James Richters via fpc-pascal, <
> fpc-pascal at lists.freepascal.org> wrote:
>
>> I can't seem to find any documentation or SerRead or SerReadTimeout..
>> searching for either along with Freepascal doesn't get me any results.
>> If it exists somewhere and I am just missing it, can someone tell me where
>> it is?
>>
>> Anyway, what I'm trying to figure out is when the timeout timer starts...
>>
>
> FPC uses the OS provided functionality to interact with the serial port.
> On Windows the timeout seems to start when the read request is made (
> https://learn.microsoft.com/en-us/previous-versions/ff547486(v=vs.85)).
> On POSIX (at least Linux) it depends on the specific set of flags specified
> , scroll down to the discussion on canonical/noncanonical mode for the
> details (https://linux.die.net/man/3/termios).
>

A bit more information after peeking into the source code: on win32 the
timeout information can be read or set using Get/SetCommTimeouts. The
COMMTIMEOUTS structure (
https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-commtimeouts)
contains a read interval timeout and total timeouts for read & write
operations. SerReadTimeout sets the ReadTotalTimeoutConstant value, so
basically the total timeout duration.

On Linux SerReadTimeout uses a fpSelect on the handle with the specified
timeout, so in principle it is the same behaviour as on Windows, i.e. a
total timeout.

While both OSs provide some functionality to specify inter character
timeouts, FPC does not directly expose this functionality in the Serial
unit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20220919/2c536533/attachment.htm>


More information about the fpc-pascal mailing list