Subject: Solaris 2.x modem/terminal how-to, Rev 10/9/93

From: [email-masked] (Celeste Stokely)
Date: Tue, 30 Nov 1993 14:29:55 GMT

(It seems to be time for me to post this again, judging from the number
of requests I'm getting for it.)

The Answerbook instructions on setting up modems and terminals under
Solaris 2.x are wrong, because they turn a few back-quotes into forward
quotes. The Answerbook's procedure is also not very easy to understand.

Here is a more cookbook approach, with a couple of useful scripts you
can easily modify to suit your needs.

Enjoy!

..Celeste Stokely
Unix System Administration Consultant, Stokely Consulting
EMAIL:          [email-masked]
Voice Line:     415-967-6898 / FAX: 415-967-0160
USMAIL Address: Stokely Consulting 
                211 Thompson Square / Mountain View CA 94043

Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 1

        Configuring Terminals and Modems under Solaris 2.x
        ==================================================
                        Revision 10/9/93

                            INDEX
                            -----

Setting up a terminal on Solaris 2.x.................Section A.....Page 2
    BEFORE YOU BEGIN: SET UP THE TERMINAL............Section A.1...Page 2
    ENABLING SOLARIS FOR A TERMINAL..................Section A.2...Page 2
    add_terminal script............................................Page 3
Setting Up a Bidirectional Modem on Solaris 2.x......Section B.....Page 4
    BEFORE YOU BEGIN: SET UP THE MODEM...............Section B.1...Page 4
    ENABLING SOLARIS FOR A BIDIRECTIONAL MODEM.......Section B.2...Page 4
    add_modem script...............................................Page 6
More on tip and /etc/remote..........................Section C.....Page 7
    /etc/remote example............................................Page 8
Setting other serial port modes......................Section D.....Page 9
    /etc/ttydefs examples..........................................Page 10
Random notes of various uses of serial ports.........Section E.....Page 11
   Parity in UUCP..................................................Page 11
   Flow control with UUCP..........................................Page 12



Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 2

A. Setting up a terminal on Solaris 2.x

*********************************************************************
***                      IMPORTANT NOTES:                         ***
***   1. All single quotes in these directions are BACK QUOTES,   ***
***     not FORWARD QUOTES, except where specifically noted.      ***
***                                                               ***
***   2. Be sure and execute these commands as root, from a       ***
***     BOURNE shell (sh), not ksh, tcsh, or csh. (If you put the ***
***     commands into a Bourne shell script, that's fine, too.)   ***
***                                                               ***
***   3. If, after following these instructions, you get          ***
***     terminal failures, and you're not using a script, then    ***
***     make sure that root's default shell is /sbin/sh and not   ***
***     csh.                                                      ***
*********************************************************************

A.1 BEFORE YOU BEGIN: SET UP THE TERMINAL
        - Set the terminal for the speed you wish (example below
          assumes you are using 9600 baud)
        - The only lines you really need in the terminal-to-Sun cable
          are 2, 3, and 7. Be sure to cross lines 2 and 3 in your cable.
        - Set the terminal for Xon/Xoff flow control
        - Set the terminal for 7 bits, Even Parity. (1 stop bit, if
          you have that setting.) If you want a different parity or
          word length, see Section D of this document.

A.2 ENABLING SOLARIS FOR A TERMINAL:
        - Save the following script as add_terminal
        - make it executable with "chmod u+x add_terminal"
        - Edit add_terminal to meet your particular needs
        - Execute add_terminal
        - If the terminal doesn't give you a login when you hit <return>
          try rebooting the machine once.

#!/bin/sh
#
##########################################################################
# add_terminal shell script. Must be run as root from bourne shell
# Change these parameters as needed for your particular needs.
# PARAMETER                MEANING
# ---------                -------
# -s ttya                  terminal is on ttya. you may want ttyb
# -d /dev/term/a           actual port device. you may want /dev/term/b
# -l 9600E                 speed/stty setting from /etc/ttydefs. choose an
#                          entry that meets your needs
# -T tvi925                your default terminal type for this port. This
#                          is a terminfo terminal type
# -i 'terminal disabled'   message sent to the tty port if the port is
#                          ever disabled
#     QUOTE-ALERT: The single quotes the port-disabled message are
#                  FORWARD QUOTES
##########################################################################
# Remove any existing port monitor on ttya


Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 3

# (Change the "ttya" to "ttyb" if that's the port you're dealing with)
#
pmadm -r -p zsmon -s ttya
#
# Create the new port monitor
#
#     QUOTE-ALERT: The single quotes in the port-disabled message
#                  [terminal disabled] are FORWARD QUOTES
#
pmadm -a -p zsmon -s ttya -i root -fu -v 1 -m "`ttyadm -l 9600E \
-d /dev/term/a -T tvi925 -i 'terminal disabled' -s /usr/bin/login -S y`"


Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 4

B. Setting Up a Bidirectional Modem on Solaris 2.x
==================================================

B.1 BEFORE YOU BEGIN: SET UP THE MODEM
  Be sure that the modem is configured for the following:

    - Hardware DTR, when the Sun drops DTR the modem should hang up and
      reset the modem.
    - Hardware Carrier Detect, the modem only raises the CD line when
      there is an active carrier signal on the phone connection. When carrier
      drops, either when the other end of the connection terminated or if
      the phone connection is broken, the Sun will be notified and
      act appropriately.  The CD signal is also used for coordinating dial-in
      and dial-out use on a single serial port and modem.
    - Respond with numeric result codes. (Usually this is ATV0)
    - Sends BASIC result codes ONLY. (Sometimes this is ATX0 or ATQ0)
    - Does not echo commands. (Usually this is ATE0)
    - Modem is locked at a single speed setting between Sun and modem.
      Speed may vary as needed between local and remote modem, but
      should remain constant between Sun and modem.

B.2 ENABLING SOLARIS FOR A BIDIRECTIONAL MODEM

*********************************************************************
***                      IMPORTANT NOTES:                         ***
***   1. All single quotes in these directions are BACK QUOTES,   ***
***        not FORWARD QUOTES, except where specifically noted.      ***
***                                                               ***
***   2. Be sure and execute these commands as root, from a       ***
***        BOURNE shell (sh), not ksh, tcsh, or csh. (If you use     ***
***     the a Bourne shell script, that's ok.)                    ***
***                                                               ***
***   3. If, after following these instructions, you get          ***
***     modem failures, or if step #7 gives an error message      ***
***     about "ttyadm: -V: invalid parameter", then make sure     ***
***     that root's default shell is /sbin/sh and not csh.        ***
*********************************************************************

1. Login as root and  type:
        prompt# eeprom ttya-ignore-cd=true
        prompt# eeprom ttya-rts-dtr-off=true
   >> go to step 2

2. Reboot the system by typing:
        prompt# init 6
   >> Go to step 3

3. Make sure the modem is properly connected and configured.
   Make sure the cable is ok.
   >> Go to step 4


Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 5

4. Is zsmon configured and running?
   (The following instructions assume that the modem cable to serial port A.)
   Login as root and type:
        prompt# sacadm -l -t ttymon

   If you get a message like:
      "Invalid request, zsmon does not exist"
      then the zsmon port monitor is not configured.
   >> Go to step 5

   If you get a result like:
       PMTAG          PMTYPE         FLGS RCNT STATUS     COMMAND
       zsmon          ttymon         -    0    ENABLED    /usr/lib/saf/ttymon
   >>  Go to step 6

5.  To configure the zsmon port monitor

      prompt# sacadm -a -p zsmon -t ttymon -c /usr/lib/saf/ttymon \
              -v `ttyadm -V` -y "dial in/out on serial port a"

      (Note: zsmon = PMTAG
             "dial in/out on serial port a" = "any comment")
    >>  Go to step 6

6. Is ttymon configured and running?
   Type:
      prompt# pmadm -l -s ttya                         (where ttya is the SVCTAG)

   a) If there is no service, you will get a result like: the

           Service <a> does not exist.
      >> Go to step 7.

   b) If you got a result like:

      PMTAG          PMTYPE         SVCTAG         FLGS ID         <PMSPECIFIC>
      zsmon          ttymon         ttya           u    root   /dev/term/a I - /

      Then you need to remove the existing service by typing:
            prompt# pmadm -r -p zsmon -s ttya
                                 ^        ^
                               (PMTAG)  (SVCTAG)
      >> Go to step 7.


Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 6

7. Make a script which will remove any existing port monitor and create a new
   bidirectional port service.

   (Putting this in a script is a Very Good Idea because if you make a mistake,
   you can easily fix the problem and rerun the script. Don't try to do this
   without a script--there are too many typing errors waiting to be made in
   this command.

   Type in the following script as a file (for instance, /sbin/add_modem),
   make it executable, then run it:

#!/bin/sh
#
##########################################################################
# add_modem shell script. Must be run as root from bourne shell
# Change these parameters as needed for your particular needs.
# PARAMETER                MEANING
# ---------                -------
# -p zsmon                 PMTAG / name of this port monitor
# -s ttya                  SVCTAG / modem is on ttya. you may want ttyb
# -d /dev/term/a           actual port device. you may want /dev/term/b
# -l contty5H              ttylabel, defined in /etc/ttydefs file (speed
#                          setting.
#                          contty5H=19200 baud. see ttydefs for other baud rates)
# -b                       flag for bidirectional port use
# -S n                     turn software carrier off (modem supplies hardware
#                          carrier detect signal)
# "dial in/out on serial port a"  this is a comment you'll see on pmadm -l
##########################################################################
# Remove any existing port monitor on ttya
# (Change the "ttya" to "ttyb" if that's the port you're dealing with)
#
pmadm -r -p zsmon -s ttya
#
# Create the new port monitor
#
pmadm -a -p zsmon -s ttya -i root -v `ttyadm -V` -fu -m \
"`ttyadm -d /dev/term/a -s /usr/bin/login -l  contty5H -b -S n -m \
ldterm,ttcompat`" -y "dial in/out on serial port a"
#
#end of add_modem script
#####################################################################

    Make the script executable by typing
        prompt# chmod 700 /sbin/add_modem
    then actually run it with:
        prompt# /sbin/add_modem

    >> Go to step 8.


Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 7

8. TIP and /etc/remote

    Edit /etc/remote and find the entry beginning with "hardwire:". Change
    the portion which says:
        :dv=/dev/??????:
    to read
        :dv=/dev/cua/a:    (or /dev/cua/b if you're using the B port)

    Change the portion which says:
        :br#somenumber:
    to read
        :br#9600:   (or 19200, or whatever baud rate you plan to use)
    >> Go to step 9

9. Type:
   prompt#  tip hardwire
               you should see "connected"
   type:
      ATE1V1<carriage return>
               you should see "OK"
    >> Go to step 10
    If you don't see "OK", you are not communicating with the modem.
    See if the modem is plugged in, verify the baud rate of the modem
    and the hardwire entry in /etc/remote, verify the modem cable.

10. Test the dialin
    Test your modem setup by dialing into the Solaris 2.x machine. If
    you get logged in, congratulate yourself!
    >> Go to step 11

11. Further setup for using the modem
    At this point, you have established basic outgoing computer-to-modem
    setup. If you plan to use uucp, then start setting up the /etc/uucp
    files. (This is left as an exercise for the reader.)
    If you are interested in more ways to use tip with your modem, see
    Section C of this document.
    >> Go To Section C


Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 8

C. More on tip and /etc/remote
==============================
1. The cuaa entry (below) allows you to type "tip cuaa" and talk
directly to a modem on port a at 2400 baud.

2. "tip phonenumber" will look for the tip0 entry and use that
definition. (In the example below, it will use tip0, which points to
UNIX-2400, which sets up a dialup 2400 baud hayes compatible modem.
UNIX-2400 points to dialers, which references /dev/cua/a.

3. "tip mysystem"  (below) looks up the "mysystem" entry, and dials the
number 14155551212 via a 19200 baud connection on /dev/cua/a.

The following sample file is set up for
        port a, 2400 baud hayes compatible modem
        port b, 9600 baud modem, may or may not be hayes compatible

/etc/remote example:
====================

cuaa:dv=/dev/cua/a:br#2400
mysystem:pn=14155551212:tc=UNIX-19200:
hardwire:\
        :dv=/dev/cua/b:br#9600:el=^C^S^Q^U^D:ie=%$:oe=^D:
tip1200:tc=UNIX-1200:
tip0|tip2400:tc=UNIX-2400:
tip9600:tc=UNIX-9600:
tip19200:tc=UNIX-19200:
cu1200:tc=UNIX-1200:
cu0|cu2400:tc=UNIX-2400:
UNIX-1200:\
        :el=^D^U^C^S^Q^O@:du:at=hayes:ie=#$%:oe=^D:br#1200:tc=dialers:
UNIX-2400:\
        :el=^D^U^C^S^Q^O@:du:at=hayes:ie=#$%:oe=^D:br#2400:tc=dialers:
UNIX-9600:\
        :el=^D^U^C^S^Q^O@:du:at=hayes:ie=#$%:oe=^D:br#9600:tc=dialers:
UNIX-19200:\
        :el=^D^U^C^S^Q^O@:du:at=hayes:ie=#$%:oe=^D:br#19200:tc=dialers:
dialers:\
        :dv=/dev/cua/a:
--------------------------------------------------------------------
The attributes are:
dv      device to use for the tty
du      make a call flag (dial up)
pn      phone numbers (@ =>'s search phones file; possibly taken from
                              PHONES environment variable)
at      ACU type
ie      input EOF marks (default is NULL)
oe      output EOF string (default is NULL)
cu      call unit (default is dv)
br      baud rate (defaults to 300)
tc      to continue a capability


Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 9

D. Setting other serial port modes
==================================
Serial port modes (the terminal I/O options found in stty(1) ) are set in the
file /etc/ttydefs. The name of the serial port mode (like contty5H) is used
as the argument to the "-l" option in the "ttyadm" portion of the "pmadm
-a" command. (This is the "speed" setting you use when you add a new port
monitor.) See the stty man page for all the available terminal I/O options.

The format of the entries in ttydefs is defined as:

   ttylabel:initial-flags:final-flags:autobaud:nextlabel

   ttylabel     The string ttymon tries to match against the TTY port's
                ttylabel field in the port monitor administrative file.
                It often describes the speed at which the terminal is
                supposed to run, for example, 1200.

  initial-flags Contains the initial termio(7) settings to which the
                terminal is to be set. For example, the system administrator
                will be able to specify what the default erase and kill
                characters will be. initial-flags must be specified in the
                syntax recognized by the stty command.

   final-flags  final-flags must be specified in the same format as
                initial-flags. ttymon sets these final settings after a
                connection request has been made and immediately prior to
                invoking a port's service.

   autobaud     If the autobaud field contains the character `A', autobaud
                will  be enabled.  Otherwise, autobaud will be disabled.
                ttymon determines what line speed to set the TTY port to by
                analyzing the carriage returns entered. If autobaud has been
                disabled, the hunt sequence is used for baud rate determination.

   nextlabel    If the user indicates that the current terminal setting is
                not appropriate by sending a BREAK, ttymon searchs for a
                ttydefs entry whose ttylabel field matches the nextlabel field.
                If a match is found, ttymon uses that field as its ttylabel
                field.  A series of speeds is often linked together in this
                way into a closed set called a hunt sequence. For example,
                4800 may be linked to 1200, which in turn is linked to 2400,
                which is finally linked to 4800.

 WARNING: These stty modes are processed from left to right within each set
 of "initial-flags" or "final-flags". So, the order of the modes in each
 entry is significant.

 In particular, when setting the mode to 8bits, do NOT enter it as
 ".... -parity ... sane", but as "... sane... -parity" because "sane" sets the
 port to 7 bits.



Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 10

/etc/ttydefs examples:
======================

1. contty5H, as supplied by Sun, is 19200 bps, 7 bits even parity
        contty5H:19200 opost onlcr:19200 hupcl sane::conttyH

   This is equivalent to:
        contty5H:19200 evenp opost onlcr:19200 sane evenp hupcl::conttyH
             or
        contty5H:19200 parenb -parodd opost onlcr:19200 sane parenb -parodd \
        hupcl::conttyH

2. Change contty5H to "7 bits, no parity" (-parenb)
        contty5H:19200 -parenb opost onlcr:19200 sane -parenb hupcl::conttyH

3. Change contty5H to "8 bits, no parity" (-parenb cs8, or -parity)
  contty5H:19200 -parenb cs8 opost onlcr:19200 sane -parenb cs8 hupcl::conttyH
           or
  contty5H:19200 -parity opost onlcr:19200 sane -parity hupcl::conttyH

4. Change contty5H to "7bits, odd parity" (parenb parodd, or oddp)
        contty5H:19200 parenb parodd opost onlcr:19200 sane parenb parodd \
        hupcl::conttyH
           or
        contty5H:19200 oddp opost onlcr:19200 sane oddp hupcl::conttyH


Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 11

E. Random notes of various uses of serial ports
===============================================
1. Parity in UUCP:
   People often get confused about running UUCP in 7bits vs. 8 bits vs. even or
   odd parity. Here's what's really going on and how to deal with it.

   Both the caller and receiver must agree on parity (even, odd, none) during
   the login sequence. 7 or 8 bit word length really doesn't matter, if you
   "do the right thing" with parity.

   Once the uucico's are running, UUCP's own protocol handles all these issues
   for you, but you need to be concerned with it during login.

   There are 4 parity-related options you can set up during the login chat:
       P_ZERO - No parity
       P_EVEN - Even parity
       P_ODD  - Odd parity
       P_ONE  - "1" or Mark parity

   It is usually safest to set up parity on a per-system-to-call basis, in the
   /etc/uucp/Systems file, but it can also be set for all uses of the port, in
   /etc/uucp/Dialers file.

    Example 1. Setting up a port within UUCP to run with no parity, on a
      per-system-connect basis.

      In the file /etc/uucp/Systems, include P_ZERO in the chat script,
      as in:

        outhost Any ACU 9600 5551212 "" P_ZERO ogin: mylogin ssword: mypass

      This means that when you first start trying to contact the machine
      "outhost" uucp expects nothing ("") and sets P_ZERO (no parity).

    Example 2. Setting up a port within UUCP to run with no parity, for all
      uses of this port.

      (This example assumes you are using the "tbfast" entry in your
      /etc/uucp/Devices file)

      In /etc/uucp/Dialers:
         tbfast  =W-,    "" P_ZERO "" \dA\pA\pA\pTE1V1X1......


Oct  9 07:57 1993  Setting up Terminals and Modems under Solaris 2.x Page 12

2. Flow control with UUCP:
   With UUCP, either use hardware flow control or no flow control. Please
   remember that there is no incoming hardware flow control on Sun CPU
   serial ports, only outgoing hardware flow control. (There is no such
   limitation on non-cpu ports which claim to have hardware flow control.)

   The lack of incoming hardware flow control is not a problem with UUCP,
   usually, because the UUCP protocol is robust enough to request
   retransmission of packets, when the data isn't correct.

   Using a good modem that has built-in UUCP protocol support (also known as
   spoofing) will also help. If all else fails, slow down the connection
   between the Sun and the modem to what you can support in your environment.

   The string "STTY=crtscts" tells UUCP to use hardware flow control. It's
   usually better to set this up on a per-port basis, rather than on a
   per-system basis, but UUCP will let you configure it however you want.

    Example 1. Setting up a port with UUCP to use hardware flow control for
      all uses of this port. (Preferred way)

      (This example assumes you are using the "tbfast" entry in your
      /etc/uucp/Devices file)

      In /etc/uucp/Dialers, add "STTY=crtscts" after the CONNECT\sFAST:

         tbfast  =W-,  "" \dA\pTE1.... \EATDT\T\r\c CONNECT\sFAST STTY=crtscts

    Example 2.  Setting up a port with UUCP to use hardware flow control, on a
      per-system-connect basis. (Do this if you feel you must, but there
      are very few good reasons for it.)

      In the file /etc/uucp/Systems, include "STTY=crtscts" in the chat script,
      as in:
        outhost Any ACU 9600 5551212 ogin: mylog ssword: mypass "" STTY=crtscts

..Celeste Stokely
Unix System Administration Consultant, Stokely Consulting
EMAIL:          [email-masked]
Voice Line:     415-967-6898 / FAX: 415-967-0160
USMAIL Address: Stokely Consulting
                211 Thompson Square / Mountain View CA 94043