termios and non-blocking write()

Aaron J. Grier aaron at frye.com
Wed May 8 01:04:35 UTC 2002

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

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