[comp.realtime] async or no-block reads of serial lines under vxWorks?

vanandel@stout.atd.ucar.edu (Joe Van Andel) (08/24/90)

Using vxWorks, I need the ability to issue a read on a serial line,
but not block forever if the device doesn't respond.

There doesn't seem to be any good, ready-made, way of doing this.  Here are 
the options I've come up with, and the problems with each:

1) Poll, using an ioctl to see if characters are waiting, to avoid blocking.

    I hate polling. :-(

2) Spawn a task to do the read, and wait on a semaphore for the task to
complete the read.  At the same time, issue a wdStart() which will call
a timeout routine if I don't cancel it.  The timeout routine does a
semGive(), and sets a timeout flag, so I know the read failed.  A
variant of this scheme would be to use a named pipe for data and
synchronization.
	
    Not too bad to code, but requires an extra dummy task per file descriptor.
    The dummy task still gets blocked forever if the external device never 
    responds.

3) Issue a wdStart() to call a timeout routine that raises a signal to
breaks my task out of its read().

    Probably won't work, since the current vxWorks manual says that 
signals won't start a pended task.  (Page 1-82, sigLib(1) manual page).

(Under Unix, I can break out of a read() with a signal, or I can call a 
select with a timeout, without invoking polling.)

4) Use RPC between the task that wants the characters and the task 
reading the serial line.  Since RPC will eventually timeout, at 
least the requesting task won't block forever.

    RPC has more overhead than using a semaphore, and still requires an 
extra task.

Does anyone have a better solution to this problem?

Please mail your responses to me.

Thanks very much.
--
	Joe VanAndel  		Internet:vanandel@ncar.ucar.edu
	NCAR - RSG  			
	P.O Box 3000		Fax:	 303-497-2044
	Boulder, CO 80307-3000	Voice:	 303-497-2071