Non-Blocking Serial I/O without Select
eric.norum at usask.ca
Fri May 25 16:03:05 UTC 2001
Mike Siers wrote:
> My application requires the use of non-blocking I/O on
> a serial port. The networking documentation states that
> a) the select() operation is very slow
> b) it only works on socket file descriptors
> I basically would like the ability to have some wakeup
> call back functions that are similar to what is provided
> for sockets. RTEMS added the SO_SNDWAKEUP and SO_RCVWAKEUP
> options to the setsockopt() function. This allows an
> application to register some wakeup call back functions
> with the socket file descriptor.
> I would like to add the ability to register some wakeup
> call back functions using the ioctl() function call on a
> serial port file descriptor. This would require changes
> to the standard RTEMS termios source code.
> Has any one implemented something similar to this? What
> are the recommended ways of using non-blocking I/O on
> a serial port? I would prefer if the solution was not
> dependent on a specific BSP implementation.
> Any thoughts or comments would be greatly appreciated.
Can you split your application into two tasks?
Task A would do a blocking read on the serial line and signal task B
(event, message, semaphore -- your choice) when input is present.
Task B would do the non-blocking part of the application and obtain
input from (shared buffer, message -- your choice) when available.
Of course you can always use use explicit polling and FIONREAD.
Eric Norum eric.norum at usask.ca
Department of Electrical Engineering Phone: (306) 966-5394
University of Saskatchewan FAX: (306) 966-5407
More information about the users