*BSD News Article 40333


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msunews!uwm.edu!lll-winken.llnl.gov!fastrac.llnl.gov!usenet.ee.pdx.edu!not-for-mail
From: rkwee@ee.pdx.edu (Roland Kwee)
Newsgroups: comp.os.386bsd.questions
Subject: Serial port blocks on CARRIER
Date: 4 Jan 1995 00:56:05 -0800
Lines: 21
Message-ID: <3ednr5$nm7@cruella.ee.pdx.edu>
NNTP-Posting-Host: cruella.ee.pdx.edu
Summary: How to get the serial port to NOT block on the CARRIER line?
Keywords: serial blocking cd stty ioctl handshake
X-Newsreader: NN version 6.4.19 #2


On my FreeBSD 1.0 system, I am having a problem with using the
serial port carrier signal. On startup, it is in mode -clocal.
Before dialing out, the modem has the CARRIER signal on False,
but this makes the port 'hang'. Even 'stty' hangs when I try
to set clocal. With the program fragment below, I finally had
a way to set the port to clocal:

	fd=open(argv[1], O_RDWR|O_NONBLOCK);
	tcgetattr(fd, &tbuf);
	tbuf.c_cflag |= CLOCAL;
	tcsetattr(fd, TCSANOW, &tbuf);

        Note the flags O_NONBLOCK and TCSANOW.

Question: Is this really the best way to do it? Is there no
way to run stty in non-blocking mode?

Thanks for any help.

--Roland Kwee    email: rolandkwee@acm.org