Hayes command set

From Wikipedia, the free encyclopedia

Telephone network modem standards

ITU V-Series | V.92 | K56flex | X2 | MNP | Hayes command set


Most dialup modems follow to a large extent the specifications of the Hayes Command Set, a specific programming language originally developed for the Hayes Smartmodem 300 modem. The modem initialization string consists of a series of commands. It prepares the modem for communications, setting such features as dialing mode (tone or pulse), waits, detection of the busy signal and many other settings. Newer modem communications programs reset the initializations string for users according to which menu options they have selected or according to the enabled features. Mostly, the user does not see or type these commands, or even know about them.

Contents

[edit] History

Prior to the introduction of the Bulletin Board System (BBS), modems typically operated on dedicated point-to-point telephone lines that always terminated to a modem at the far end. In other situations, the user would dial the phone manually before connecting, or pick it up if it rang. In a few cases the computers themselves had to call a selection of numbers, and for this task they used a separate "dialer", plugged into a different input/output port on the computer (typically an RS-232 port).

When Dennis Hayes designed his first "smart modem" in 1977, he encountered a problem that no previous modem manufacturer had faced: how to tell the modem what phone-number to dial, using only one port. One solution could have used a separate set of "command pins" dedicated to sending and receiving commands. Another could have used a signal pin indicating that the modem should interpret incoming data as a command.

Instead, in order to save money, Hayes chose to re-use the existing data pins with no modification. The modem could switch itself to one of two modes:

  1. data mode in which the modem sends the data to the remote modem. (A modem in data mode treats everything it receives from the computer as data and sends it across the phone line).
  2. command mode in which data is interpreted as commands to the local modem (commands that the local modem should execute).

To switch from data to command mode an escape sequence string of three plus signs followed by a pause of about a second was sent (to go to the command mode without losing the connection), and to switch back you sent the online command, O. In actual use many of the commands automatically switched to the online mode after completion, and it is rare for a user to use the online command explicitly.

This use of in-band signalling leads to a potential serious problem: what if the data being sent in data mode contains three plus signs? This could happen randomly quite easily, and it would happen any time someone attempted to send data describing the system – this document for instance. In order to reduce the chance of this problem the pause at the end of the escape sequence was required, if any other data was received within one second of the three plus signs, it was not the escape sequence and would be sent as-is.

The command set includes commands for various phone-line manipulations, dialing and hanging up for instance. It also includes various controls to set up the modem, including a set of register commands which allowed the user to directly set the various memory locations in the original Hayes modem. The command set was copied largely verbatim, including the meaning of the registers, by almost all early 300 baud modem manufacturers, of which there were quite a few.

The expansion to 1200 and 2400 baud required the addition of a small set of new commands, some of them prefixed with a & to denote those dedicated to new functionality. However Hayes was slow to move to higher speeds or the use of compression, and three other companies led the way here – Microcomm, U.S. Robotics and Telebit. All three used their own additional command sets instead of waiting for Hayes to lead the way.

Soon a plethora of new models appeared, including new ones from Hayes, following one sort of standard or another. Things became simpler again during the widespread introduction of 14.4 and 28.8 kbaud modems in the early 1990s. Slowly a set of commands based heavily on the original Hayes extended set using "&" commands became popular, and then universal. The only other command-set still popular, the US Robotics set, has survived due to the popularity of US Robotics devices.

The command set was unprotected, but the concept of a "guard time" after the escape sequence was patented. In the late 1980s Hayes started enforcing the patent, charging $1 per modem that used it. Many later modems thus did not implement the guard time; this eventually (when modems began to be used to dial up to the Internet) led to a nasty denial-of-service attack involving an ICMP echo request ("ping") packet containing three plusses and ATH, the hangup command.


[edit] Description

The following is a partial list of the Hayes command set. (also called the AT commands, AT is short for attention).

The Hayes Command Set can be divided into four groups:

  • Basic Command Set - A capital character followed by a digit. For example, M1.
  • Extended Command Set - An “&” (ampersand) and a capital character followed by a digit. This is an extension of the basic command set. For example, &M1. Note that M1 is different from &M1.
  • Proprietary Command Set - Usually started by either a backslash (“\”), or a percent sign (“%”), these commands vary widely among modem manufacturers.
  • Register Commands - Sr=n where r is the number of the register to be changed, and n is the new value that is assigned.

A register is a specific physical location in memory. Modems have small amounts of memory onboard. This fourth set of commands is used to enter values in a particular register (memory location). The register will be storing a particular variable (alpha-numeric information) which is utilized by the modem and communication software. For example, S7=60 instructs your computer to “Set register #7 to the value 60”.

Although most commands are defined by a letter-number combination (L0, L1 etc.), the use of a zero is optional. In this example, L0 is the same as a plain L. Keep this in mind when reading the table below.

Here are some of the most important characters that may appear in the modem initialization string. These characters normally should not be changed.

  • AT - Tells the modem that modem commands follow. This must begin each line of commands.
  • Z - Resets the modem to its default state.
  • , (a comma) - Makes the software pause for a second. More than one can be used 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 the terminating Carriage Return character to the modem. This is a control code that most communication software translates as a carriage return. (Note, when this is sent to the modem, it is sent as a single byte, ASCII CR (0x0D), or "Control-M" not the two characters ^ and M.)
  •  ; (a semi-colon) - Return to command mode immediately after dialing. This makes it possible to dial more than 45 digits numbers or to walk through interactive menus for example.
  • W - wait for dialtone. The modem will wait for a dialtone before dialing numbers following the W. There is a timeout that must not be exceeded for this to work, generally configured in the S7 register.
  •  ! - flash hook. put quickly the modem on/off hook.

When in data mode an escape sequence is used to return the modem to command mode. The normal escape sequence is three plus signs ("+++"), and to disambiguate it from possible real data, a guard timer is used: it must be preceded by a pause, not have any pauses between the plus signs, and be followed by a pause; by default a "pause" is one second and "no pause" is anything less.


[edit] Compatibility

While the original Hayes command set was a huge leap forward, with time many problems set in, almost none of them due to Hayes per se:

  • Since there was no written standard, other modem manufacturers just copied the external visible commands and (roughly) the basic actions. This led to a wide variety of subtle differences in how modems changed from state to state, how they handled error conditions, hangups, and timeouts.
  • Each manufacturer tended to add new commands to handle emerging needs, often incompatible with other modems.

For example, setting up hardware or software handshaking often required a slew of different commands for different modems. This undermined the handy universality of the basic "AT" command set.

  • Many "hayes-compatible" modems had serious quirks that made them effectively incompatible. For example, many modems required a several second pause after being given the "AT Z" reset command. Others required spaces between commands, others did not. Some would unhelpfully change baud rate of their own volition, which would leave the computer with no clue how to handle the incoming bits.

As a result of all this, Eventually many comm programs had to give up any sense of being able to talk to all "hayes compatible" modems, and instead the programs had to try to determine the modem type from its responses, or provide the user with some option whereby they could enter whatever special commands it took to coerce this particular modem into acting properly.

[edit] The Basic Hayes Command Set

Command Description Comments

A0 or A

Answer incoming call  
A/ Repeat last command Don't preface with AT, don't follow with carriage return. Enter usually aborts.

B0 or B

Call negotiation V32 Mode/CCITT Answer Seq. Today, most modems ignore this command, though they answer "OK" for compatibility.
B1 Call negotiation Bell 212A Answer Seq. Ignored by most modern modems.
B2 Call negotiation Verbose/Quiet On Answer. Ignored by most modern modems.
D Dial

Dial the following number and then handshake in originate mode.
P - Pulse Dial
T - Touch Tone Dial
W - Wait for the second dial tone
R - Reverse to answer mode after dialing
@ - Wait for up to 30 seconds for one or more ringbacks
, - Pause for the time specified in register S8 (usually 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

E0 or E

No Echo Will not echo commands to the computer
E1 Echo Will echo commands to the computer (so one can see what one types)
H0 Hook Status On hook - Hang up
H1 Hook status Off hook - phone picked up

I0 or I

Inquiry, Information, or Interrogation This command is very model specific. I0 usually returns a number or code, while higher numbers often provide much more useful information. Today, Windows uses this for Plug and Play detection of specific modem types.

I3 or I

Information (3) This command, on newer modems, usually returns the make and model number of the modem. For example: ATI3 returns LT V.90 Data+Fax Modem Version 6.00.

L0 or L

Speaker Loudness. Modems with volume control knobs will not always have these options. Off or low volume
L1 Low Volume
L2 Medium Volume
L3 Loud or High Volume

M0 or M

Speaker off M3 is also common, but different on many brands
M1 Speaker on until remote carrier detected (i.e. until the other modem is heard)
M2 Speaker is always on (data sounds are heard after CONNECT)

N0 or N

Handshake Speed Handshake only at speed in S37
N1 Handshake at highest speed larger than S37

O0 or O

Return Online Returns the modem back to the normal connected state after being interrupted by the "+++" escape code.
O1 Return Online after an equalizer retrain sequence

Q0 or Q1

Quiet Mode Off - Displays result codes, user sees command responses (e.g. OK)
Q1 Quiet Mode On - Result codes are suppressed, user does not see responses.
Sn Select current register

Note that Sn, ? and =r are actually three separate commands, and can be given in separate AT commands.

Select register n as the current register
Sn? Select register n as the current register, and query its value. Using ? on its own will query whichever register was most recently selected.
Sn=r Select register n as the current register, and store r in it. Using =r on its own will store into whichever register was most recently selected.

V0 or V

Verbose Numeric result codes
V1 English result codes (e.g. CONNECT, BUSY, NO CARRIER etc.)

X0 or X

Smartmodem Hayes Smartmodem 300 compatible result codes

X1

Usually adds connection speed to basic result codes (e.g. CONNECT 1200)
X2 Usually adds dial tone detection (preventing blind dial, and sometimes preventing ATO)
X3 Usually adds busy signal detection.
X4 Usually adds both busy signal and dial tone detection

Z0 or Z

Reset Reset modem to stored configuration. Use Z0, Z1etc. for multiple profiles. This is the same as &F for factory default on modems without NVRAM (non volatile memory)

[edit] Voice command set

Main article: Voice modem command set

Modems with voice or answering-machine capabilities support a superset of these commands to enable digital audio playback and recording.

[edit] See also

[edit] External links

In other languages