*BSD News Article 19077


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!metro!sequoia!ultima!kralizec.zeta.org.au!kralizec.zeta.org.au!not-for-mail
From: bde@kralizec.zeta.org.au (Bruce Evans)
Newsgroups: comp.os.386bsd.misc
Subject: Re: Using the sio ports with a Modem
Date: 2 Aug 1993 17:57:50 +1000
Organization: Kralizec Dialup Unix Sydney: +61-2-837-1183 V.32bis
Lines: 80
Message-ID: <23ihduINNpre@kralizec.zeta.org.au>
References: <1872@dcsc.dla.mil> <1993Jul30.000604.28487@fcom.cc.utah.edu>
NNTP-Posting-Host: kralizec.zeta.org.au

In <1993Jul30.000604.28487@fcom.cc.utah.edu> terry@cs.weber.edu (A Wizard of Earth C) writes:

>In article <1872@dcsc.dla.mil> cp01395@dcsc.dla.mil (Duane L. Rezac) writes:
>[ ... ]
>>comcontrol seems to work, and if I echo something to the device, I 
>>see the rd and sd lights flash, but I am unable to control the modem 
>>(i.e atz ats0=1 have no effect).
>>...
>>I have set up the tty00 with stty to 2400 baud, -clocal, and all
>>other settings are at the default.

>You aren't going to get result codes or command echo (ie: modem input to
>the computer) unless DCD is asserted 

Yes he is, provided he uses cua00 to talk to the modem or changes the
-clocal to clocal.  [sio doesn't handle clocal right for bidirectional
ports.  The best workarounds for now are:

(1) if you use only the dialin ports for dialin:
	keep clocal off always, using something like:
	    stty -clocal before starting getty
	    periodic stty -clocal in case some crazy user turned clocal on

(2) if you use only the dialin ports for dialout:
	keep clocal on always, using something like:
	    stty clocal before each session

(3) if you use only the dialout ports for dialout but don't use the
    dialin ports for dialin:
	same as (2) works but is not necessary for initial dialout;
	One of Andrew Chernov's fixes makes it unnecessary for repeated
	dialouts/

(4) if you use the dialin ports for dialin and the dialout ports for
    dialout:
	same as (1).

>or unless you modify the driver to
>act correctly with the partial open hack... ie:

act INcorrectly and allow the partial open hack? :-)  The hack isn't
really necessary with the bidirectional ports.

>	int	fdp;
>	int	fd;
>	char	*port = "/dev/my_serial_port_name_this_week";

>	/* open, ignoring carrier*/
>	fdp = open( port, O_RDWR | O_NDELAY);

>	/*
>	 * open again, respecting carrier (carrier is ignored because of tty
>	 * flags from last open)
>	 */
>	fd = open( port, O_RDWR);

>	close( fdp);

This won't work with sio (or the old com driver, except that the old
driver faked carrier always being on) because the last open didn't set
any tty flags (at least you didn't show them being set).  I think the
following simpler variant of it works:

	fd = open(port, O_RDWR | O_NONBLOCK);
	fcntl(fd, F_SETFL, 0);

>(Alarm calls and error checking omitted).  This code is what should live
>in cu, uucp, tip, slattach, and freinds of the family.

Too many places.  Given bidirectional ports, these programs can just open
the dialout port, then set CLOCAL to whatever is appropriate.

>Many stty flags are only effective for the duration of the open in the
>stty program.  Beware of settings changing back to default but pretending
>to be set.  ...

This is not a problem with the current version of sio.  It never sets
flags back to defaults unless instructed to do so.  This may change.
-- 
Bruce Evans  bde@kralizec.zeta.org.au