[Lazarus] Serial communication??

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Wed Sep 29 17:39:38 CEST 2010


Michael Schnell wrote:
>  On 09/29/2010 01:26 PM, Mark Morgan Lloyd wrote:
>>
>> But the serial does allow you access to the handle, so it's trivial to 
>> use select() (actually fpSelect()) to implement the timeout.
> Is spSelect() portable / Cross-Platform ?

It certainly is in the context of socket programming, I've not checked- 
yet- the situation with serial ports and general files.

However if I recall correctly low-level Windows read and write syscalls 
have their own timeout parameters, so the correct thing would be to wrap 
(for example) serial.pp and TComPort in a mid-level object and then 
implement things like event notification at that level.

> interface based on functions and Object Pascal Events that (if not 
> especially stated in the docs) are fired in the context of the main 
> thread.

I agree. But on the other hand I think it's a mistake to write low-level 
support with too many embedded assumptions, using serial comms for 
illustration you might want events to go to the main thread if writing a 
terminal emulator but not if writing a multithreaded store-and-forward 
server.

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