This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: How to handle serial port input?


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]