Subject: Re: serial port control
To: Jaromir Dolecek <>
From: Simon J. Gerraty <>
List: current-users
Date: 02/11/1998 12:56:50
Jaromir Dolecek writes:
>open(2). I've looked at some sources and tried O_NONBLOCK
>option to open. Now the program doesn't block, but I can't write
>anything (Input/Ouput error on write(2)). read(2) returns without error,
>but doesn't read anything too.

If the UPS is not asserting DCD you need to either tie it to DTR or
add CLOCAL to c_cflag.  Eg:

>	tcgetattr(d, &tty);
>	cfsetspeed(&tty, 1200);
	tty.c_cflag |= CLOCAL;
	if (tcsetattr(d, &tty) < 0) {

note that the call to tcsetattr() is need before cfsetspeed()
has any effect.  See cfsetspeed(3).