MacArthur, Ian (SELEX GALILEO, UK) wrote:
>> To integrate the above with FLTK is probably best done with
>> either a thread, or creating your own Fl::run() loop using
>> Fl::wait() with some small timeout, so you can poll back and
>> forth between FLTK and the serial port.
>
> Oh yes, that's a point - serial comms is very slow, so you do need to
> "detach" it from the GUI interaction in some way. I always use threads
> for this, but I guess polling in a timeout would work OK too, and be
> simpler to set up.
You should never have to block for long, no matter how slow
the serial connection is; just pull in chars that are ready,
and don't wait (for very long) for new chars.
Use the SetCommTimeout() to make sure you never wait for very
long for data, and just accumulate characters that /are/ ready
into a buffer, then when you get a complete 'command' fire off
a handler to manage it.
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev