####[ How-Do-I Documents ]######################################

Sub : Modem Initialisation Strings                      HDI #003

How-Do-I write modem initialisation strings ? All these strings
people talk to me about remains a big puzzle ! 

################################################################

Index

1        Introduction
2        The Hayes Command Set
3        Why Hayes initialisation strings
4        Where are they used
5        Basic Command Set
6        Extended Command Set
7        Proprietory Command Set
8        Register Command Set
9        How to make an init string
10       Kudos and Brickbats

#################################################################
 

1        Introduction

1.1      All modems are configurable. They  have  processors  in
         them and a wee bit of  programmed sequences  accessable
         through external commands to  internal registers.  This
         way your  communication  requirements can be fine tuned
         for your specific line, be it to connect to an ISP, let
         some one dial in, send a fax, or voice comn.
         
         
2        The Hayes Command Set         
             
             
2.1      Here is a  description  of the  Hayes Command Set. Most 
         of the modem follow this set ... and is virtually uni-
         versal today.
         
2.2      Modem manuals today, by and large are rather skimpy ...
         and even if detailed, you  probably  will never find it
         at the hour of need ... or someone borrowed it, and you
         forgot who ...
         
2.3      You want to turn your modem speaker off. Is it ATM0 ???         
         You need a place to search it up ... well, its here.
         
2.4      This document is by no means a  comprehensive list, but
         it gives the essential things as a ready reference.             
                 

3        Why Hayes initialisation strings

3.1      The modem initialization string consists of a series of 
         commands. It  prepares the modem for communications ...
         setting up features such as  dialing mode, detection of
         busy signal and a host of ther things.
         
3.2      The set of strings and conventions were  developed by a
         hardware firm (Hayes), and  became  a de-facto standard 
         for subsequent manufacturers. These strings  are either
         original or derived from the  original Hayes modem set.
         For many years Hayes modems  have been the standard. As 
         the players in the field increased for reasons of being
         "compatible" they adhered to most of the Hayes commands
         (similar to IBM compatibility for PCs, and Epson compa-
         tibility to printers).

4        Where are they used ?

4.1      This is a familiar territory ... obviously,  with  dial-
         ing software, and the term init  string is known to even
         a newbie. These strings are quite unique, they  are  NOT
         case sensitive, but to make the string humanly readable,
         and avoid any ambiguity here are  some  guidlines, which
         would be easier to follow:
         
         o use UPPER case
         o use backslash "\" seperators between adjacent commands 
           since proprietory  commands are  usually preceded by a 
           "\" and, this is  equivalent to  typing  each  command 
           on a new line. Example:
           
           AT&F\E0\V1\&C1\&D2\S95=47\S10=250\X3\L3

4.1.1    [Note : This is the classical teaching.  Most modems now
         days accept a jumbled string ... even under such a situ-
         ation, at least a  space  seperator should be maintained
         for better readability and maintenance. The above string
         with spaces would be : AT&F E0 V1 &C1 &D2 S95=47 S10=250
         X3 L3] ... Legibility makes a difference. ALL  modems do
         accept "\" seperators though ...]
                     
4.2      This type of habit makes the entry neat, and  there  are
         no chances of errors ... But  what does the above mean ?
         Well, that is what the whole HDI is about ...
         
4.3      Broadly speaking, the Hayes Command Set  can  be divided
         in to 4 groups:         
         
         o Basic Command Set
         o Extended Command Set
         o Proprietary Command Set          
         o Register Commands          
         
             
5        Basic Command Set 

5.1      These deal with call negotiations, dialing, speaker and
         such hardware related attributes .. These are always in
         UPPER case, and followed by a digit (e.g. A0, M1 etc).
         
5.2      These are the most commonly used  command strings.  The
         full set in alphabetical order is placed below:

################################################################

The Basic Hayes Command Set - Alphabetical

Command     - Description -           Comments

################################################################

A0 or A	    Answer incoming call

A/          Repeat last command.      (Don't preface with AT. 
                                      Enter usually aborts.)

Remarks : Not frequently used. For answering incoming calls use
          the string noted later ...

################################################################

B0 or B     Call negotiation          V32 Mode/CCITT ans Seq 
B1          Call negotiation          Bell 212A Answer Seq 
B2          Call negotiation          Verbose/Quiet On Answer

Remarks : Not frequently used.

################################################################

D           Dial                      Dial the following number 
                                      and then handshake.
					 
            Dial Modifiers

            (These are common but most modems may have more.)

            P - Pulse dial 
            T - Touch Tone dial 
            W - Wait for second dial tone 
            , - Pause for time specified in register S8 
                (default 2 seconds) 
            ; - Remain in command mode after dialing 
            ! - Flash switch-hook (Hang up for a half second as 
                in transferring a call)
            L - Dial last number 

Remarks : Either ATDP or ATDT is invariably used, though for most
          modems these days, ATDT is the factory set default. The
          other options are rarely used.
          
#################################################################

E0 or E    No Echo                    Will not echo commands to 
                                      the computer

E1         Echo                       Will echo commands to the 
                                      computer.
                                       
Remarks : It is always better to set this to E1  so one can see 
          what is being typed. In most modems E1 is default.

################################################################

H0 or H    Hook status                On hook - hang up

H1         Hook status                Off hook - phone picked up

Remarks : Not frequently used in init strings.  Used by communi-
          cation software, or through your programs/ scripts.
           
#################################################################

I0 or I   Inquiry, Information,       (This command is very model 
          or interrogation            specific.I0 usually returns 
                                      a number or code, which can
                                      be  used  for  specifically 
                                      for your model)

Remarks : For model specific programming. Not frequently used.

################################################################

L0 or L   Speaker Loudness            Off or low volume
L1        Speaker Loudness            Low volume 
L2        Speaker Loudness            Medium volume
L3        Speaker Loudness            Loud or high volume 

Remarks : The level of loudness depends upon the model, and you
          need to find the optimal level of  loudness  for your
          own modem [Note: Modems with built-in volume  control  
          knobs may not have these options.]

################################################################

M0 or M	  Speaker Off                 (Some modems use M3)
M1        Speaker Off                 Speaker on until remote 
                                      carrier detected 
M2        Speaker On                  Speaker is always on (data 
                                      sounds are heard after 
                                      CONNECT)

Remarks : The default for most modems is M2. To switch off all
          sounds from your modem use M0 (or M3 for some modems
          which will be stated in your  user  manual, or found 
          out after trial and error)                                     

#################################################################

N0 or N   Handshake Speed             Handshake only at speed in 
                                      S37 register

N1        Handshake Speed             Handshake at highest speed 
                                      larger than S37

Remarks : The default is N0 for most modems, and the default hand
          shake speed (2400 bauds usually) is adequate under most 
          conditions for initial handshake ... A higher speed may
          cause handshake failure with poorer lines.
          
#################################################################

O0 or O   Return Online               O0 see also X1 as dial tone 
                                      detection may be active
O1        Return Online               Return Online after an 
                                      equalizer retrain sequence

Remarks : Not normally used. This conflicts with dial tone detect
          which is normally set. The  default for  most modems is
          O1
          
#################################################################					

Q0 or Q   Quiet mode                  Off - Displays result codes
                                      user sees command responses 
                                      (e.g. OK)
Q1        Quiet mode                  On - Result codes are supp-
                                      ressed, user does not see 
                                      responses
                                      
Remarks : The default is suppression of  responses (Q1) for  most
          modems. if the full responses are required, it  is best
          to set it on with Q0 in the init string. It is a common
          folly that people mistake display quietness with volume
          level of the modem speakers, and think that  placing Q0
          will achieve silence/ quiteness !                                     

#################################################################

Sn?	   Store (Query)              Query contents of S-regi-
                                      ster n

Sn=r       Store                      Store value r in S-regi-
                                      ster n

Remarks : This is a  programmers tool,  and NOT  needed  for init 
          strings. A brief writeup on S-registers is given later. 
          It is beyond the scope of this  HDI into go into all S-
          register specifics, and  there are a  lot of variations 
          here between modems.
          
#################################################################

V0 or V	   Verbal?                    Numeric result codes

V1         Verbal?                    English result codes (e.g. 
                                      CONNECT, BUSY, NO CARRIER 
                                      etc.)

Remarks : The default for most modems is V1, but there is no harm 
          in setting this  explicitly  in the init string. Nobody 
          will be in a position to interpret a number as BUSY and 
          another as NO CARRIER ! It needs to be verbal (V1).
          
#################################################################

X0 or X	   Smartmodem                 Hayes Smartmodem 300 compa-
                                      tible result codes

X1         Smartmodem                 Adds connection speed to 
                                      basic result codes 
                                      (e.g. CONNECT 1200)

X2         Smartmodem		      Adds dial tone detection 
                                      (preventing blind dial)

X3         Smartmodem                 Adds busy signal detection

X4         Smartmodem                 Adds both busy signal and 
                                      dial tone detection

Remarks : The default is X0, and  anything above that will result 
          in the connect speed being displayed. If you just  want  
          a dial tone detection (not recommended  through EPABX),
          X2 is adequate. Normally this feature is NOT needed and  
          detection of BUSY signal (X3) suffices. The  X4  option
          merely combines X2 and X3 together, not normally used.

          					
#################################################################

Z0 or Z	   Reset              Reset modem to stored configuration 
                              (Z0, Z1 etc. for multiple profiles)
                              (Same as &F (factory default) on 
                              modems with out NVRAM (non volatile
                              memory)

Remarks : This is not commonly used these days  since most modems
          these days come with NVRAM and days of volatile RAM are
          over. The &F commands act for  both  and  are preferred
          over Z commands.
          
#################################################################


5.3      So far so good ... we have just covered the  basic Hayes
         modem commands and there are still more to go ...
         

6        Extended Command Set 

6.1      This  set  encompasses  areas  like  test, detect, error
         control and similar things. All  these  commands have an
         "&" (ampersand) prefix, a capital  character followed by
         a numerical digit ...  This is an extension of the basic 
         command set. For example, "&Q0". [Note that  "Q1" of the
         basic set (quite mode) is not the same as "&Q0" (no data
         buffering)].

6.2      These are the most commonly used  command strings of the
         extended set. The set in alphabetical order is below:


################################################################

The Extended Hayes Command Set - Alphabetical

Command     - Description -           Comments

################################################################

&B0 or &B  Retrain Parameters      Disable auto retrain function

&B1        Retrain parameters      Enable auto retrain function

&B2        Retrain parameters      Enable auto retrain, but dis-
                                   connect if no line improvement 
                                   over period dictated by S7
                                   (wait time for remote carrier)
                                   
Remarks : The wait time for remote carrier is set in S7 register
          which may vary from 0-255 sec. This setting is factory
          set, and can be set by hand as well. The  default here
          is B1 or enable auto-retrain, depending upon the line.
          If disabled, it disconnect wothout retrain trial. This
          parameter is not normally set in init strings.
                                             

#################################################################

&C0 or &C  Carrier detect           signal always on

&C1        Carrier Detect           Indicates remote carrier 

Remarks : The default is &C1. The LED comes on with  the presence
          of the remote carrier. No point having  the  signal all
          the time. No  harm putting  it in the  init string as a
          safety measure.
          
#################################################################

&D0 or &D  Data Terminal Ready 	  Signal ignored  
           (DTR)

&D1        DTR                    If DTR goes from On to Off the 
                                  some modem  goes  into command 
                                  mode 

&D2        DTR                    Some modems hang upon DTR On to 
                                  Off transition. 

&D3        DTR                    Hang up, reset modem and return 
                                  to command mode upon DTR
                                  
Remarks : Once the data terminal is established, there is no need
          for the modem to remain in command mode. &D2  should be
          the default (and it is so for most modems) for  digital
          communication. This can be set in your init string.                                 


#################################################################

&F0 or &F  Factory defaults        Generic Hayes defaults.

&F1        Factory Defaults       Factory defaults tailored to an 
                                  IBM-PC compatible user

&F2        Factory Defaults       Factory defaults for a Mac 
                                  w/software handshaking

&F3        Factory Defaults       Factory defaults for a Mac 
                                  w/hardware handshaking
 
Remarks : This is usually a good thing to use in your init string, 
          since the &F1-&F3 settings  can vary  among modems, and 
          they  may actually be the cause of connection problems. 
          If you are making an  init string,  it is  advisable to
          start with &F, and reset to factory settings before you
          start adding to it ... This does NO harm anywhere !  In
          other words ALWAYS begin with "AT&F ...."

#################################################################

&K0 or &K  Local flow control     Disable local flow control

&K1        Local flow cotrol      Enable RTS/CTS hardware local 
                                  flow control

&K2        Local flow control     Enable XON/XOFF software local 
                                  flow control

&K3        Local flow control     Enable RTS/CTS hardware local 
                                  flow control

&K4        Local Flow Control     Enable XON/XOFF software local 
                                  flow control
                                  
Remarks : The default for most modems is &K1 (hardware flow con-
          trol). Note &K3 and &K4 merely duplicate &K1  and &K2.
          In some modems they are set that way. Check your modem
          manual, to see if yours has that quirk ! Can be stated
          explicitly in init string.
          

#################################################################

&P0 or &P  Pulse dialing ratio    U.S./Canada pulse dialing 
                                  39% make/ 61% break ratio

&P1        Pulse Dialing Ratio    U.K./Hong Kong pulse dialing 
                                  33% make/ 67% break ratio

Remarks : Usually not required to be set. Most  modems can adjust
          automatically to both.  Pulse  dial  exchanges in India
          follow &P1 method (UK/HK)
          
##################################################################

&Q0 or &Q  Error Control mode      Asynchronous non-EC more. 
                                   No data buffering. ASB disabled.

&Q5        Error Control mode      Select V.42 EC operation 
                                   (requires flow control)

&Q6        Error Control Mode      Asynchronous mode with ASB 
                                   (requires flow control)

&Q8        Error Control mode      Select alternate EC protocol 
                                   (MNP)

&Q9        Error Control mode      Conditional data compression: 
                                   V.42bis = yes, MNP5 = no
                                   
Remarks : This is model/hardware specific.Please check your modem
          manual for quirks. The usual default is &Q0. 

#################################################################

&S0 or &S  DSR Action Select       Always on (default)

&S1        DSR Action Select       Follows EIA specification 
                                   (Active following carrier tone
                                   and until carrier is lost)
                                   
Remarks : Default is &S0 for all  modems, and  does  not need any
          change unless your modem recommends it (see manual).
          
#################################################################

&Y0 or &Y   Select Configuration   Load profile 0 (default)
            Loaded at power up
		
&Y1 	    -do-                   Load profile 1

Remarks : These are modem specific. Some modems cater for differ-
          ent profiles to be executed at power up. If your modem
          caters for such things, this may be of some use.

#################################################################


6.3      Half the job done ... extended set of commands  ( common
         ones at least have been covered ... now  to  proprietory
         set ....

7        Proprietory Command Set 

7.1      This set has no fixed rules.  It is  different  in diff-
         erent models ... and therefore do not  follow  any  laid
         down standards. These  commands are  usually  started by 
         either a backslash ("\"), or a percent sign ("%"). These 
         commands vary so  widely among modem manufacturers, that
         only the commonly used ones are stated here. Look up the
         manual that came with your  modem  for ones specific for
         your modem.
         
7.2      These are the most commonly used  command strings of the
         proprietory set. The set in alphabetical order is below:

7.3      Needless to say, unless  specifically  advocated in your
         modem manual, none of these are actually  required to be
         put in your init string.
         
#################################################################

The Proprietory Hayes Command Set - Alphabetical

Command     - Description -           Comments

#################################################################

\A0 or \A  Character maximum      64 character maximum
           MNP block size

\A1        -do-                   128 character maximum

\A2        -do-                   192 character maximum

\A3        -do-                   256 character maximum

##################################################################

%C0 or %C  Data Compression       Disabled 
           Enable/Disable 

%C1        -do-                   MNP5 Enabled

%C2        -do-                   V.42bis (BTLZ) Enabled

%C3        -do-                   MNP5 & V.42bis (BTLZ) Enabled

#################################################################

%D0 or %D  Data compression       512 BLTZ dictionary size

%D1        -do-                   1024 BLTZ dictionary size

%D2        -do-                   2048 BLTZ dictionary size

%D3        -do-                   4096 BLTZ dictionary size

#################################################################

%E0 or %E  Escape method          ESCAPE DISABLED

%E1        -do-                   +++AT method (default)

%E2        -do-                   <BREAK>AT method

%E3        -do-                   BOTH methods enabled

%E4        -do-                   Disable "OK" to +++

%E5        -do-                   Enable "OK" to +++

################################################################

\J0 or \J  DTE Auto Rate          Disabled
           Adjustment
J1         -do-                   DTE rate is adjusted to match 
                                  carrier rate.

#################################################################

\N0 or \N  Connection type        Normal connection (see below 
                                  for definitions)

\N1        -do-                   Direction connection

\N2        -do-                   MNP Auto-reliable connection

\N3        -do-                   Auto-reliable connection

\N4        -do-                   V.42bis reliable link with 
                                  phase detection

\N5        -do-                   V.42bis auto-reliable link 
                                  with phase detection

\N6        -do-                   V.42 reliable link with phase 
                                  detection

\N7        -do-		          V.42 auto-reliable link with 
                                  phase detection


#################################################################


8        Register Command Set 

8.1      A register  in  computer  parliance  has something to do 
         with a specific physical location in memory. All  modems
         have some amount of memory on board. This  set  of modem
         commands is to change these  physical values so that the
         modem momn software can utilise the set values. e.g. the
         command S7=40 will set register #78 to 60 (and wait time
         for remote carrier will be set to 40 seconds).  
         
8.2      The number of S Registers in a  modem is not  fixed, and
         varies from model to model. Some have dozens of such "S"
         registers, but only the first few are standard. The syn-
         tax for changing a register value is  ATSn=N ... and the
         current value is examined with ATSn?
          
8.3      These are the more commonly used  command strings of the
         register set. The set in alphabetical order is below:

         
#################################################################

The Register Hayes Command Set - Alphabetical

S-Registers:

Reg	Range		Default	   Function

#################################################################

S0      0-255 rings     1-2        Answer on ring number Don't 
				   answer if 0

S1      0-255 rings     0          If S0>0 this register counts 
                                   incoming rings

Remarks : These can be used for incoming calls for a dial-in box
e.g.  For a Hayes modem with a fixed 115200 bps interface to the
machine this init string invoked through agetty  turns off modem 
echo and result codes, makes  modem/ computer DCD  track  modem/
modem DCD,  makes  a DTR drop cause a dis-connection and turn on
auto-answer after 1 ring : Add to /etc/inittab:
/sbin/agetty  -w  -I  'ATE0Q1&D2&C1S0=1\015'   115200 ttyS1  
                                                      
S2      0-127 ASCII     43 +        Escape to command mode 
                                    character 

S2      &gt;127                     no ESC

S3      0-127 ASCII     13 CR       Carriage return character

S4      0-127 ASCII     10 LF       Line feed character

S5      0-32,127 ASCII  8 BS        Backspace character 

S6      2-255 seconds   2           Dial tone wait time (blind 
                                    dialing, see Xn)

S7      1-255 seconds   30-60       Wait time for remote carrier

S8      0-255 seconds   2           Comma pause time used in 
                                    dialing

S9      1-255 1/10 sec.	6           Carrier detect time required 
                                    for	recognition

S10     1-255 1/10 sec. 7-14        Time between loss of carrier 
                                    and hangup

[e.g. "AT S10=70 S1?"  would  tell the  modem  not to hang up for 
seven seconds should it not hear the answering modem,  and return 
the number of times the phone last rang]

S11	50-255 millisec. 70-95      Duration and spacing of tones
                                    when tone dialing

S12     0-255 1/50 sec.  50         Guard time for pause 
                                    around +++ command sequence

S36     Fallback options when error correction link fails:  
        0 - Disconnect                  
        1 - Establish Direct connection
        3 - Establish Normal connection
        4 - Establish MNP connection if possible else Disconnect
	5 - Establish MNP connection if possible else Direct 
	    connection
	7 - Establish a MNP connection if possible, else Normal 
	    connection

S37 	1 = 300 bps		(Initial Handshake)	
	5 = 1200 bps                            
	6 = 2400 bps
	7 = 1200/75 bps (v.23 mode)
	8 = 4800 bps
	9 = 9600 bps
	10 = 12000 bps
	11 = 14400 bps
	12 = 7200 bps 

#################################################################


9        How to make an init string

9.1      Having gone through the  details above would  have given
         yopu a fair amount of insight. The process is quite easy
         and rational, and you can make it yourself. The  basic &
         the extended set of  commands are  usually  adequate and 
         these are common  for all modems.  For  proprietory  and 
         "S" register commands, you would have to go through your
         modem manual ... there are too many quirks here !

9.2      The common denominator

9.2.1    These are the standard tokens used in init strings:

         AT  =  tells the modem that modem commands follow. 
                This must begin each line of commands.

         Z   =  resets the modem to default state

         , (comma) =  makes your software pause for a second. You 
         can use  more than one , in a row.  For example,  ",,,,"  
         tells the  software to pause four seconds. (The duration 
         of the pause is governed by the setting of register S8).

         ^M  =  sends "Carriage Return"  to the modem.  This is a 
          control code that most communication software translate 
          as a "carriage return."

9.3      General guidelines are as follows:

         o ALWAYS start by setting to default ( viz. AT&F )
           
         [ Note:  Although most commands are defined by a letter-
           number combination (L0, L1, etc.),  the  use of a zero 
           is optional. &F is the same as &F0].
         
         o Add only things that are necessary, and no more.
         
         o See what are the characteristics that you want, and
           cross-check with the list above ... just fill that !         
         
         o Some common ones are:

           M0 .... Modem speaker off (M3 in some)
           M2 .... Modem speaker always on
           L1 .... Soft modem sound         
           L3 .... Loud modem sound
           E1 .... Echo commands to the computer
           Q0 .... Display result codes                       
           V1 .... Verbose, non-numeric codes
           X3 .... Add BUSY signal detection
           &C1 ... Indicates when remote carrier registered
           &D2 ... Hang on DTR On to Off
           &P1 ... If on PULSE dial exchange
           &Q0 ... No data buffering
                                  
9.4        By now, I hope it was possible to clarify  some of the
           concepts involved in writing modem init strings. It is
           not possible to remember the various options available
           and it is aleays better to  have the  specifics tucked
           away somewhere, from where details can be found. It is
           with these two motives, that this HDI has been made.
           

#################################################################

10       Kudos and Brickbats

10.1     This document is released under GNU/ GPL licence. You are
         free to use and distribute this without any encumberances

10.2     Any kudos and brickbats should be directed at:

         USM Bish <bish@nde.vsnl.net.in>

         30 Sep 2001