Subject: Re: MODEMS on tty ports (part II)
To: Ernst J. du Toit <ernstjdt@maxwell.ctech.ac.za>
From: Ken Hornstein <kenh@entropic.com>
List: netbsd-help
Date: 12/16/1994 12:16:44
>I've compiled C-Kermit and it using it currently for my comms. Now I can't
>set the carrier behavoir of NetBSD like I'm used to (/dev/ttyiXX or
>stty -f /dev/ttyXX clocal etc. ala my old FreeBSD). I solve this
>currently by just hard strapping CD on my US Robotics Courier. But this
>solution is not ideal.
>
>My old ppp scripts don't run either, after much staring and with great
>help form a UNIX guru friend he concluded that the POSIX changes was
>doing wat they are supposed to do. In the ppp script pppd is run with a
>chat script. CHAT gets the port up, but when it exists to hand the link
>over to pppd POSIX resets the port to it's defaults and pppd ends up ....

Ummm... are you having the chat script run from inside of pppd?  (ie - with
the "connect" argument to pppd?)  If so, then pppd will open the port for you,
and fire up chat with it's stdin/stdout connected to the specified port.
If you do that and want to still have the right carrier behavior, you'll need
to hack pppd to open the port with the O_NDELAY option.  You can do this on
line 351 of /usr/src/usr.sbin/pppd/main.c.  You'll want it to be:

    if ((fd = open(devnam, O_RDWR | O_NDELAY)) < 0) {

This works for me.

Now that we're on the subject of this .... I am thinking - would it make sense
for this to be triggered via the "modem" command-line option?  Something like:

    if ((fd = open(devnam, O_RDWR | (modem ? O_NDELAY : 0))) < 0) {

for the abovementioned line.  Since this is something that would only happen
with a modem attached, and pppd already does some other extra stuff when you
give it the "modem" keyword, that it makes sense to do it.  It certainly would
make it easier for the average user who wants to use pppd with a modem!

--Ken