termios and non-blocking write()

Mike Siers mikes at poliac.com
Wed May 8 14:30:22 UTC 2002


Hi Aaron,
A while back I submitted some patches to the termios code
in the snapshots that you might be interested in.

The updated termios code allows you to register some callback
functions via an ioctl() call.  I added the values
RTEMS_IO_SNDWAKEUP and RTEMS_IO_RCVWAKEUP.  When a callback
function is registered, it will be invoked when the termios
buffer is empty or when the termios buffer has just received
more data.  This added feature was designed to be similar to
the socket options SO_SNDWAKEUP and SO_RCVWAKEUP feature that
is described in the RTEMS Network Supplement.

It should be pretty easy to add this patch to the RTEMS 4.5
source code.

Hope this helps,
Mike Siers


-----Original Message-----
From: Aaron J. Grier [mailto:aaron at frye.com]
Sent: Tuesday, May 07, 2002 8:05 PM
To: RTEMS mailing list
Subject: termios and non-blocking write()


I'm needing to do some non-trivial serial I/O on my RTEMS 4.5.0 target.
I've got polled-mode termios glued to an exar 161550 via the ns16550
routines, and it appears to work as advertised.  (hooray for code
reuse!)

what is the "standard" way to perform non-blocking write()s with
termios?  I found some talk on rtems-snapshots from december 1999 about
reworking the serial code after 4.1.0, but apparently there's still work
to be done.  :)

for reads, I can manipulate VMIN and VTIME to get appropriate
non-blocking behavior, but for writes it appears that the retry is
hard-wired in ns16550_write_polled() at 1000 iterations, without any
error-reporting mechanism in case the retry is tripped.  I'm prepared to
patch this up, but before I go off on my own warped path with this code,
is there a "standard unix termios" method akin to VMIN and VTIME for
write() that would apply to read()?  opening with mode O_NONBLOCK,
maybe?  is there a standard way to set the timeout in this case?

also, where did 100ms granularity for VTIME come from?  I'm considering
breaking it, and curious if there are any other implementations of
termios that have done this "nicely."

as a friend told me, termios is kind of the bastard stepchild of unix,
but it's an existing API and better than nothing.  ;)

-- 
  Aaron J. Grier  |   Frye Electronics, Tigard, OR   |  aaron at frye.com




More information about the users mailing list