[Lazarus] Serial communication??
Bo Berglund
bo.berglund at gmail.com
Fri Oct 1 11:10:36 CEST 2010
On Fri, 01 Oct 2010 08:53:45 +0200, Luca Olivetti <luca at wetron.es>
wrote:
>> (How) Can SyncObjs be used to from a thread fire asynchronous events in
>> the main thread that are scheduled "between" the GUI events that are
>> fired asynchronously anyway ?
>
>Oh, I thought you were talking about protecting access to
>variables/structures, for that you can use cross-platform the classes
>defined in syncobjs.
>To fire events in the main thread there's synchronize, but you're right,
>that's not asynchronous.
>
I (the OP) simply want to have a serial comm function that can enable
me to communicate with the hardware data acquisition system we use.
For this I need to send commands (binary packets) to the equipment and
then wait for results.
Some interchanges are command driven, such that my program sends a
command and then waits for the response. But the size of the response
cannot be determined in advance, it depends on the data. However for
these transfers the first 6 bytes of the response contains information
on the total length of the packet to expect.
A transfer can take a rather long time; if we are dealing with the max
size (1 Mbytes) and the speed 19200 it will be about 9 minutes, which
requires a non-blocking approach. Otherwise the application will die
in the eyes of the user.
Some interchanges are initiated from the equipment itself once an
initial command has been sent. These messages can come at any time;
within a few seconds or after several hours.
When I implemented the interface on Windows I could use events from
the serial component. I have tried different componets like TSerial
(by P Crowther) and AsyncPro and they all have an event signalling the
arrival of new data. So in the event procedure I can receive and
briefly analyze the data to see if I have a complete packet or not. If
I have then I can set a flag to this effect and the main code can look
at this and act when it gets set. Works fine and does not lock up the
application.
So now I am after a serial comm implementation for Lazarus/Fpc to work
in a Linux embedded environment which gives me these possibilities.
So far most of what has been shown builds on Synaser or similar, which
are blocking systems....
Bo Berglund
More information about the Lazarus
mailing list