Subject: Blocked I/O on serial ports
To: None <port-sparc@netbsd.org, tech-kern@netbsd.org>
From: Ruschmeyer, John <jruschme@att.com>
List: port-sparc
Date: 08/07/1998 11:01:04
I'm hoping you can helpe me with a problem I'm having porting an application
from Linux to NetBSD (or at least help me understand the differences between
the two environments....

I'm trying to drive an X-10 controller from a SPARCStation 2 running
NetBSD/Sparc 1.3.2. The particular controller is a CM11A.

The application I am trying to run is called 'heyu'. It was written on
Linux/x86 and is based on a program called 'x10' writen for the older CP290
controller. Although, the author feels the code "should" be portable to
other Unixes, I'm having problems with a NetBSD/Sparc port.

First, a major non-portability- The code uses the old 2-argument version of
open(2) which is still supported by Linux as well as the newer (POSIX?)
3-argument version. The latter being the only version of open() supported by
NetBSD. The change, of course, is simple.

Now, however, I hit the next problem- open() won't complete unless I use the
O_NONBLOCK option. I assume that this is because the CM11A is not asserting
the modem control lines.

Specifcally, the CM11A has a 4-wire serial interface: TD, RD, SG, and RI
(ring indicator).

Heyu does not seem to have been written for non-blocked I/O, however. The
major routines which read the serial port all use unchecked read(2) calls
which usually return EAGAIN. I have put in result tests and loops (a good
idea anyway), but it makes the background daemon process very processor
intensive, looping on tight read loops.

So, is there a way under NetBSD to get blocked I/O working to this device? I
assume that if I can get open() to complete then the rest will take care of
itself. No? Also, is this a genuine difference between the two OS's or just
a quirk of the Sparc?

Thanks...


<<<John>>>

"One World, One Web, One Program" - Microsoft Promotional Ad
"Ein Volk, Ein Reich, Ein Fuhrer" - Adolf Hitler