[fpc-pascal] (Unix) serial port handling

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Fri Mar 18 23:01:35 CET 2011


Henry Vermaak wrote:
> On 09/03/11 11:30, Mark Morgan Lloyd wrote:
>> Henry Vermaak wrote:
>>> On 08/03/11 10:30, Mark Morgan Lloyd wrote:
>>>> Can anybody say whether there is a good reason that serial.pp lacks a
>>>> function to read the CD signal?
>>>>
>>>> Is SerFlush, which calls fpfsync, intended to discard input data, 
>>>> output
>>>> data or both?
>>>
>>> fsync just makes sure all the in-kernel caches are written to the
>>> device. Flushing input data is just a matter of reading it.
>>
>> Thanks for that Henry. Obviously there's scope for confusion here with
>> the kernel's tcflush() and tcdrain() functions, where tcflush discards
>> input and/or output data.
> 
> You're right.  Thinking about it, I don't know what the use of an fsync 
> is in SerFlush, since you still don't know if it's been transmitted. I'd 
> consider this a bug, SerFlush should use tcdrain.

It occurs to me that an fsync could possibly have a useful effect if a 
badly-written driver (or suspect hardware) occasionally lost Tx interrupts.

I've submitted a patch as 0018946. I don't know whether anybody else is 
using this unit but I'm trying not to break anything: I've marked 
SerFlush as deprecated and added SerSync and SerDrain which are 
non-destructive, and SerFlushInput and SerFlushOutput which are 
destructive. This brings naming into line with the termio API, and 
hopefully means that anybody working at this level doesn't have to 
import termio explicitly.

Next job is writing Win-32 equivalents.

-- 
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 mailing list