[comp.sys.mips] uu-status and modem on Magnum/digiboard port

pbickers@tamaluit.phys.uidaho.edu (Paul Bickerstaff) (06/07/91)

I have a minor problem which I can't fathom:   We have a
Magnum 3000 running RISCos 4.51 and I've put a Practical Peripherals
(Hayes compatible) modem on one of the ports of a 16-port Digiboard
card (RJ45 - DB25 straight through cable).  I've set uugetty running
on this port (/etc/inittab entry):

d3:234:respawn:/usr/lib/uucp/uugetty -h -t 60 -r ttyd3 dm2400 none LDISC0

and /etc/gettydefs entry:

dm2400# B2400 CLOCAL MDMBUF # B2400 CLOCAL MDMBUF SANE TAB3
#\r\n\n$HOSTNAME login: #dm2400

(and have tried HUPCL here without it curing the problem).

The problem is that the port gets locked and stays locked.  More precisely,
the first time someone dials in (after I change things) the port does not
lock  (!! which I'm sure it should) but only locks when the user exits and
stays locked thereafter.  (At least the lock file only appears in
/usr/spool/locks
when the user exits and stays there until I step in and remove it.) My belief
is that the port should be locked when in use and not otherwise.

Now this is only a minor problem because the modem is desired mainly for
dial-ins and it appears to work fine for this purpose despite the above
behaviour (though see the remarks below on ownership).  However, I would
like the modem available for dialing out, if desired, and besides, the
following
repeated mail messages to root are driving me nuts:

        Subject: uu-status
        Apparently-To: uucp

        LCK..ttyd3: 3443
         F S     UID   PID  PPID  C PRI NI     ADDR     SZ   WCHAN    STIME TTY
     TIME COMD
        10 S    root  3443     1  0  28 20 801103e8     71 c013f740
22:35:30 tty
d3    0:00 /usr/lib/uucp/uugetty -h -t 60 -r t

I know that if I were to be satisfied with just dial-ins I could just
run getty on
the port but I feel that would be an unsatisfying solution :-)  (if it's
a solution
at all -- I have n't tried it.)

Some further info: 

the device ownership and permissions are being interfered with; currently 
(with the thing locked) we have:

% ls -l /dev/ttyd3
crw--w--w-   1 uucp     theory    32,  3 Jun  6 08:29 /dev/ttyd3

I initially set the permissions to 664 and the group to daemon, in accordance
with recommended (Nemeth et al.) practice.  Theory is the group of the
person who last logged in via the modem.  (Don't know what happens if
somebody in another group trys to dial-in.  The problem is not likely to
arise :-) ) 

I also have added these entries to the Devices file:

Direct ttyd2 - 1200 direct #ups
Direct ttyd3 - 2400 direct
#ACU cul3 cua3 2400 hayes
#ACU cul3 cua3 1200 hayes
ACU ttyd3 - 2400 hayes

but don't think that is relevant to the present problem.

If anybody knows what I'm overlooking I'd sure appreciate the magic
recipe.

Many thanks in advance,
Paul

Paul Bickerstaff                 Internet: pbickers@tamaluit.phys.uidaho.edu
Physics Dept., Univ. of Idaho    Phone:    (208) 885 6809
Moscow ID 83843, USA             FAX:      (208) 885 6173

trevc@tecate.mips.com (Trevor Cotton) (06/07/91)

In article <1991Jun06.190435.24051@groucho>, pbickers@tamaluit.phys.uidaho.edu (Paul Bickerstaff) writes:
|> I have a minor problem which I can't fathom:   We have a
|> Magnum 3000 running RISCos 4.51 and I've put a Practical Peripherals
|> (Hayes compatible) modem on one of the ports of a 16-port Digiboard
|> card (RJ45 - DB25 straight through cable).  I've set uugetty running
|> on this port (/etc/inittab entry):
|> 

The following explains how to correctly set up uugetty/cu.

One thing it does not mention is permissions.
The very first time you try to use the line, you should set the permissions
to 666. After that, uugetty, cu and login  will manage the permissions and 
ownerships, and you should not need to ( and, in fact, you should not ) 
change them again.

 Guidelines for setting up a bi-directional modem on a MIPS box
 --------------------------------------------------------------
 
1) The serial port used MUST have modem control enabled ( that is,
   CLOCAL must be off ). The easiest way to do this is to use a device
   name with a minor number > 128. All the current MIPS serial drivers
   will default to using modem control on a serial line if the device
   minor number is > 128 and the kopt _riscos_ttys_default_clocal is
   set to 0 ( the default ) .  So, for example, if we wanted to connect
   the modem to the second serial port on an RC3240 machine, we would
   use the device /dev/ttym1.  Not all MIPS serial ports support modem
   control. Refer to section 2.7.8 of the RISCos 4.50 Release Notes
   for details on which ports support modem control.  Please note that
   if CLOCAL is off, MDMBUF should NOT be set on. These are mutually
   exclusive.

   The following information was in the RISCos 4.0 Release notes, but
   was omitted from the 4.5 Release notes. Here it is again :-

	"...In addition, the kopt _riscos_ttys_default_clocal has been
	added, with default value of ``enabled'', to retain backward
	compatibility with RISC/os 3.10.  If enabled, terminal lines
	default to CLOCAL enabled for minor devices numbered 0
	through 127, and CLOCAL disabled for minor devices numbered
	128 through 255.  If the kopt is disabled, the above CLOCAL
	defaults are reversed, to more closely match the behavior of
	other UNIX systems.  (MIPS has adopted the Sun convention
	that terminal minor device i, 0<=i<=127, is the same as
	terminal minor device i+128, except that the CLOCAL default
	is inverted for one, relative to the other.) " 

2) The modem that is connected must be set up so that it only raises
   DCD when a connection has been established to another modem. This
   is normally the default for modems.

   The reasons for 1) and 2) above are :

  -uugetty opens the serial line, and then sleeps waiting for DCD to
   come true.  Once DCD comes true, uugetty will attempt to create a
   lockfile in the /usr/spool/locks directory, and then issue a login
   prompt. If a lockfile already exists ( indicating cu is already
   using the line ) uugetty will go back to sleep.

  -cu always opens the line without waiting for DCD, and so can use
   the same device name. When cu starts up, it tries to create a
   lockfile in /usr/spool/locks.  If one already exists, and the process
   that created that lock file is still running, cu will exit.

3) Cabling is very important, and differs depending on what type
   of MIPS serial port is being used. Detailed information is printed
   in the RISCos 4.50 Release Notes, section 2.7.6.

   The aim is to make sure that as well as TX, RX and GND being correct,
   DCD from the modem is connected to the relevant input pin on the
   MIPS port, and that DTR out from the MIPS is connected to the
   correct modem input pin.

   So, for example, to connect a modem to the second serial port on
   an RC3240 the cable to use would be

			MIPS ttym1       modem

			 2  ------------- 2
			 3  ------------- 3
			 5  ------------- 8
			 7  ------------- 7
			 20 ------------- 20


   To connect a modem to a Digiboard port, the following cable
   should be used:

			MIPS ttydm??	modem

			 2  ------------ 2
			 3  ------------ 3
			 4  ------------ 4
			 5  ------------ 5
			 6  ------------ 6
			 7  ------------ 7
			 8  ------------ 8
			 20 ------------ 20

   Note that this cable also supports RTS/CTS flow control signals 
   ( pins 4 and 5 )

4) Flow control. Wherever possible, RTS/CTS flow control should be
   used when connecting to a modem. However, not all MIPS serial ports
   support RTS/CTS.  Refer to the RISCos 4.50 Release Notes sections
   2.7.6 and 2.7.8 for a description of what machines / ports support
   what signals on what pins.

   NOTE: If using uucp file transfer, the modem should be set up to
         NOT use XON/XOFF flow control. Generation of Xon or Xoff flow
         control characters by the modems will break the uucp file transfer
         protocol. RTS/CTS or no flow control should be used; the uucp
         protocol will handle re-transmission of lost characters.
   
5) The next thing is to set up the gettydef entry for use by uugetty.
   The following entry sets up RTS/CTS flow control and sets HUPCL.
   HUPCL makes sure that when cu or uugetty exits, and this is the
   last close of the serial line, the DTR signal from the MIPS box is
   dropped so that the modem correctly disconnects from the phone line
   and does not accept any more incoming calls.  When cu or uugetty
   re-opens the serial line, DTR will be re-asserted.
   MDMBUF should NOT be set, as we are using DTR/DCD fo modem control and
   NOT hardware handshaking.

Example /etc/gettydefs entry:

modem_19200# B19200 HUPCL #B19200 SANE HUPCL RTSCTS TAB3 #\r\n\n$HOSTNAME login: #modem_9600

Example /etc/inittab entry for starting uugetty :

t1:234:respawn:/usr/lib/uucp/uugetty -r -t 30 ttym1 modem_19200 none LDISC0


6) Modem settings. Below is an example set up for a Telebit T2500
   modem that can be used as a reference to set up other modems.


E0 F1 M1 Q0 T V1 W0 X3 Y0 &P0 &T4     Version GF7.00-T2500SA
S00:002 S01=000 S02=043 S03=013 S04=010 S05=008 S06=002 S07:060 S08=002 S09=006
S10=007 S11=070 S12=050 S18=000 S25=005 S26=000 S38=000
S41:001 S45=000 S47=004 S48=000 S49=000
S50:254 S51:254 S52:002 S54:003 S55=000 S56=017 S57=019 S58:002 S59=000
S61=150 S62=003 S63=001 S64=000 S65=000 S66:001 S67=000 S68:002 S69=000
S90=000 S91=000 S92:001 S93=008 S94=001 S95:002 S96=001 S97=000 S98=003
S100=000 S101=000 S102=000 S104=000 S105=001 S106=000 S107=020
S110=255 S111:030 S112=001
S121=000 S130:003 S131:001
S150=000 S151=004 S152=001 S153=001 S154=000 S155=000 S157=000 S158=000
S160=010 S161=020 S162=002 S163=003 S164=007 S169=000 S255=000
N0:1

   Some of the more important registers :

   S0 set to 2 tells the modem to answer incoming calls after 2 rings.

   S50 set to 254 tells the modem to attempt to connect to the remote
   modem at a speed equal to the speed that the last AT command was
   received on the interface.

   S51 set to 254 sets the default modem interface speed to Automatic
   select, with a default of 19200 ( to match the speed of our uugetty ).

   S52 set to 2 tells the modem to perform a hard reset and enter
   command mode when an on to off transition of DTR occurs. Also tells
   the modem to only answer incoming calls if DTR is true.

   S58 set to 2 tells the modem that we ( the machine ) will use full
   duplex RTS/CTS flow control. The modem will not send data when RTS
   is turned off.

   S66 set to 1 tells the modem to lock the interface speed and to
   use flow control as specified by S58 and S68.

   S67 set to 0 tells the modem to use CTS to control data flow by
   the method specified in S68.

   S68 set to 2 tells the modem to use full duplex RTS/CTS flow control.
   The modem will turn CTS off when it wants to stop flow from the
   machine.

   S131 set to 1 tells the modem to only set DCD on when carrier is
   detected from the remote modem ( that is, a connection has been
   established ).

   E0 and F1  switch the modem echo off. If this is on, then the
   uugetty may loop.  ( uugetty outputs the login prompt, the modem
   echos this back, uugetty thinks somebody is trying to log in,
   outputs the password prompt. The modem echoes this back; uugetty
   says invalid login, outputs the login prompt etc. etc. )

6) Some example uucp Dialers entries for use with the modem settings
   shown above.

	tb1200 =W-, "" A\pA\pA\pT OK ATS50=2DT\T CONNECT\s1200
	tb2400 =W-, "" A\pA\pA\pT OK ATS50=3DT\T CONNECT\s2400
	tb9600 =W-, "" A\pA\pA\pT OK ATS50=6DT\T CONNECT\s9600
	tbfast =W-, "" A\pA\pA\pT OK ATS50=255DT\T CONNECT\sFAST
	tbauto =W-, "" A\pA\pA\pT OK ATS50=0DT\T CONNECT\s

   Note that these all set the S50 register accordingly. This register
   controls how the modem chooses the speed to connect to the remote modem.

   S50 = 0 - Automatic speed determination
   S50 = 2 - 1200 bps
   S50 = 3 - 2400 bps
   S50 = 6 - 9600 bps
   S50 = 255 - FAST operation ( 19200 bps)

7) Some example uucp Devices entries for use with the above modem
   settings and Dialers entries.

   ACU ttym1 - 1200 tb1200
   ACU ttym1 - 2400 tb2400
   ACU ttym1 - 9600 tb9600
   ACU ttym1 - 19200 tbfast
   AACU ttym1 - 19200 tbauto

8) Some example uucp Systems entries for use with the above modems
   settings and Devices and Dialers entries.

  Machine1 Any ACU 1200 1234561234 "" \r login:-\r\r-login: fred word: bloggs
  Machine2 Any ACU 2400 1234561235 "" \r login:-\r\r-login: fred word: bloggs
  Machine3 Any ACU 9600 1234561236 "" \r login:-\r\r-login: fred word: bloggs
  Machine4 Any ACU 19200 1234561237 "" \r login:-\r\r-login: fred word: bloggs
  Machine5 Any AACU 19200 1234561238 "" \r login:-\r\r-login: fred word: bloggs

Summary
-------

   It is not easy to describe the exact steps to take for every type
   of modem connected to every type of MIPS serial port. The important
   thing is to understand the basic concepts. These are :
   
   The serial line being used must be using modem control. That is,
   CLOCAL is OFF.  The easiest way to do this is to use a device name
   with a minor number greater than 128.  For example, the device name
   /dev/tty1 refers to the second serial port on the RC3240. It has
   a minor number of 1, which means that the default is to not use
   modem control. /dev/ttym1 refers to the exact same port, and has
   the same major number. However, its minor number is that of
   tty1 + 128 = 129. This means that modem control is the default, i.e
   CLOCAL is OFF. This is the device to use.

   Modem control MUST be used because there must be some mechanism to
   tell uugetty that a connection to a remote modem has been made,
   and so it should wake up.  Without this, uugetty will always create
   a lockfile in /usr/spool/locks and hence cu will not be able to
   make outgoing calls, as it will see that the line is already locked.
   
   uugetty normally opens the serial line with the O_NDELAY flag clear.
   This means that when it opens a serial line with modem control
   enabled, it will go to sleep until DCD is turned on. The modem and
   cable should be set up so that DCD is switched on only when a
   connection to another modem has been made.  DCD going on wakes up
   uugetty. It looks in /usr/spool/locks for a lockfile associated
   with the serial line. If one exists, this means some other program
   ( e.g., cu ) is using the line, and so uugetty goes back to sleep
   waiting for the lock file to go away. If no lockfile exists, then
   uugetty creates one, and then outputs the login prompt.

   cu is normally able to make outgoing calls because it opens the
   serial line with O_NDELAY set; that is, it does not have to wait
   for DCD to come on.

   The other important thing to remember is that the serial line must
   have HUPCL set. This ensures that when no process has the serial
   line open, DTR out of the MIPS box is off. When uugetty and/or cu
   has the line open, DTR is on. This ensures that the modem is able
   to answer incoming calls and also that the modem correctly
   disconnects the phone line at the end of a call out.

   And finally; DO NOT USE XON/XOFF flow control if using uucp to
   transfer files ( uucico ). Use RTS/CTS flow control if the specific
   MIPS port and the modem support it; otherwise, use no flow control.
   The uucp file transfer protocol will handle re-transmission of lost
   data. ( Note. The cu 'get' and 'put' commands do not use the uucp file
   transfer protocol ).

   One final note. kermit shipped with RISCos 4.5x does not conform
   to the cu/uugetty/uucico locking protocol. kermit creates its
   lockfile in /usr/spool/uucp; uugetty etc. create their lockfiles
   in /usr/spool/locks.  Also, kermit opens the serial line with
   O_NDELAY clear, and so will block waiting for DCD.  Therefore,
   kermit cannot share a line with cu/uugetty/uucico.

END..

--trevc--

  Trevor Cotton, Sustaining Engineering, MIPS Computer Systems Inc.
  MS 6-05, 930 DeGuigne Drive, Sunnyvale, CA 94088-3650
  Tel: +1 408 524 7286  Fax: +1 408 524 7521
  Email: {wyse,ames,decwrl,pyramid}!mips!trevc    trevc@mips.com