[ECOS] How to handle serial port input?
Jesper Skov
jskov@cambridge.redhat.com
Tue Jun 19 10:13:00 GMT 2001
>>>>> "Tom" == Tom Vandeplas <tom.vandeplas@4g-radio.com> writes:
Tom> Ok this works great, thx for the input. I have one additional
Tom> question: I would like to use a larger block size (len parameter)
Tom> for performance reasons. If I do so, is it possible to set a
Tom> time-out on the thread. If for a given time no input is
Tom> generated on the serial port, how do I know when to flush it.
Tom> One possibility is to configure the device to non-blocking and
Tom> let it read the data that is available, but this isn't as nice as
Tom> the blocking version. Or is this the only possible solution?
Combine them, or use the function that queries how much is available
(I forget the key name). In pseudo code:
read(1); // blocks & sleeps
set_nonblock_mode();
read(max);
set_block_mode()
or
read(1); // blocks & sleeps
how_much_available(&len);
read(len)
I'm sure there are other ways as well.
Jesper
More information about the Ecos-discuss
mailing list