Subject: bin/5685: chat(8) needs to set onlcr
To: None <gnats-bugs@gnats.netbsd.org>
From: Simon J. Gerraty <sjg@quick.com.au>
List: netbsd-bugs
Date: 07/02/1998 01:26:23
>Number:         5685
>Category:       bin
>Synopsis:       chat(8) fails to send data to modem.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul  1 08:35:00 1998
>Last-Modified:
>Originator:     Simon J. Gerraty
>Organization:
Zen Programming...
>Release:        1.3 and 1.3.2
>Environment:
	
System: NetBSD zen.quick.com.au 1.3 NetBSD 1.3 (ZEN) #1: Sun Feb 15 23:38:24 EST 1998 root@zen.quick.com.au:/u0/usr/src/sys/arch/i386/compile/ZEN i386


>Description:
	
chat(8) reports:

Jul  2 00:51:07 zen chat[2162]: timeout set to 60 seconds
Jul  2 00:51:07 zen chat[2162]: abort on (NO CARRIER) 
Jul  2 00:51:07 zen chat[2162]: abort on (BUSY) 
Jul  2 00:51:07 zen chat[2162]: abort on (NO DIALTONE) 
Jul  2 00:51:07 zen chat[2162]: send (ATZ^M) 
Jul  2 00:51:07 zen chat[2162]: expect (OK) 
Jul  2 00:52:07 zen chat[2162]: alarm
Jul  2 00:52:07 zen chat[2162]: Failed

ie. it is getting no response at all to an ATZ.
Using pppd and chat from 1.3.2 gets the same result.

tip(1) is able to talk to modem ok at same speed.  Comparing output of
stty -a < /dev/tty01 while tip and chat are running shows:

# diff /tmp/tip.stty /tmp/chat.stty
2,7c2,7
< lflags: -icanon -isig -iexten -echo echoe -echok echoke -echonl echoctl
<       -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
<       -extproc
< iflags: -istrip -icrnl -inlcr -igncr ixon ixoff ixany imaxbel -ignbrk
<       brkint -inpck -ignpar -parmrk
< oflags: -opost onlcr -ocrnl oxtabs
---
> lflags: -icanon -isig -iexten -echo -echoe -echok -echoke -echonl
>       -echoctl -echoprt -altwerase -noflsh -tostop -flusho -pendin
>       -nokerninfo -extproc
> iflags: istrip -icrnl -inlcr -igncr -ixon -ixoff -ixany -imaxbel ignbrk
>       -brkint -inpck ignpar -parmrk
> oflags: -opost -onlcr -ocrnl -oxtabs
11c11
<       eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
---
>       eol2 = <undef>; erase = ^@; intr = ^C; kill = ^@; lnext = ^V;

of which the only output mode change is for onlcr.
Sure enough, introducing a delay in the chat script so that 

# stty onlcr < /dev/tty01

can be run in a separate window before the ATZ is sent, we get:

Jul  2 01:04:06 zen chat[2616]: timeout set to 60 seconds
Jul  2 01:04:06 zen chat[2616]: abort on (NO CARRIER) 
Jul  2 01:04:06 zen chat[2616]: abort on (BUSY) 
Jul  2 01:04:06 zen chat[2616]: abort on (NO DIALTONE) 
Jul  2 01:04:06 zen chat[2616]: send (\d) 
Jul  2 01:04:08 zen last message repeated 2 times
Jul  2 01:04:09 zen chat[2616]: send (ATZ^M) 
Jul  2 01:04:09 zen chat[2616]: expect (OK) 
Jul  2 01:04:10 zen chat[2616]: ^M 
Jul  2 01:04:10 zen chat[2616]: OK -- got it 
Jul  2 01:04:10 zen chat[2616]: send (ATDTxxxxxxxxxx^M) 
Jul  2 01:04:10 zen chat[2616]: expect (CONNECT) 
Jul  2 01:04:10 zen chat[2616]: ^M 
Jul  2 01:04:20 zen chat[2616]: ^M 
Jul  2 01:04:20 zen chat[2616]: RINGING^M 
Jul  2 01:04:32 zen chat[2616]: ^M 
Jul  2 01:04:32 zen chat[2616]: CONNECT -- got it 
Jul  2 01:04:32 zen chat[2616]: send (\d) 
...

changing the chat script to send ATZ\r\n\c manages to get an error
from the modem: 

Jul  2 00:59:49 zen chat[2207]: send (ATZ^M^J) 
Jul  2 00:59:49 zen chat[2207]: expect (OK) 
Jul  2 00:59:55 zen chat[2207]: ^M 
Jul  2 00:59:55 zen chat[2207]: ERROR^M 

the stty onlcr seems to be the only way to get it to work.

The same pppd and chat have been running ok with this setup on another
box (i486) running 1.3 since 1.3 was released.  The same setup has
been used various NetBSD releases on that system over the last 3 years
or more. 

When the modem was first connected to this system, (without a reboot)
mgetty had been running on tty01 and may have conditioned the
interface? I doubt it.  Anyway chat worked then.  After rebooting
tonight (and several reboots since) chat has behaved as described
above.


>How-To-Repeat:
	
>Fix:
	
>Audit-Trail:
>Unformatted: