Hayes command set
The Hayes command set is a specific command language originally developed by Dennis Hayes for the Hayes Smartmodem 300 baud modem in 1981.
The command set consists of a series of short text strings which can be combined to produce commands for operations such as dialing, hanging up, and changing the parameters of the connection. The vast majority of dial-up modems use the Hayes command set in numerous variations.
The command set covered only those operations supported by the earliest 300 bit/s modems. When new commands were required to control additional functionality in higher speed modems, a variety of one-off standards emerged from each of the major vendors. These continued to share the basic command structure and syntax, but added any number of new commands using some sort of prefix character –
&
for Hayes and USR, and \
for Microcom, for instance. Many of these were re-standardized on the Hayes extensions after the introduction of the SupraFAXModem 14400 and the market consolidation that followed.The term "Hayes compatible" was and as of 2018 still is important within the industry.
History
Background
Prior to the introduction of the Bulletin Board System, modems typically operated on direct-dial telephone lines that always began and ended with a known modem at each end. The modems operated in either "originate" or "answer" modes, manually switching between two sets of frequencies for data transfer. Generally, the user placing the call would switch their modem to "originate" and then dial the number by hand. When the remote modem answered, already set to "answer" mode, the telephone handset was switched off and communications continued until the caller manually disconnected.When automation was required, it was commonly only needed on the answer side — for instance, a bank might need to take calls from a number of branch offices for end-of-day processing. To fill this role, some modems included the ability to pick up the phone automatically when it was in answer mode, and clearing the line when the other user manually disconnected. The need for automated outbound dialling was considerably less common, and was handled through a separate peripheral device, a "dialler". This was normally plugged into a separate input/output port on the computer and programmed separately from the modem itself.
This method of operation worked satisfactorily in the 1960s and early 1970s, when modems were generally used to connect dumb devices like computer terminals with smart mainframe computers. However, the microcomputer revolution of the 1970s led to the introduction of low-cost modems and the idea of a semi-dedicated point-to-point link was no longer appropriate. There were potentially thousands of users who might want to dial any of the other thousands of users, and the only solution at the time was to make the user dial manually.
The computer industry needed a way to tell the modem what number to dial through software. The earlier separate dialers had this capability, but only at the cost of a separate port, which a microcomputer might not have available. Another solution would have been to use 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. Both of these had hardware support in the RS-232 standard. However, many implementations of the RS-232 port on microcomputers were extremely basic, and some eliminated many of these pins as a cost saving measure.
Hayes' solution
Hayes Communications introduced a solution in its 1981 Smartmodem by using the existing data pins with no modification. Instead, the modem itself could be switched between one of two modes:- data mode in which the modem sends the data to the remote modem..
- command mode in which data is interpreted as commands to the local modem.
In order to avoid licensing Hayes's patent, some manufacturers implemented the escape sequence without the time guard interval. This had a major denial of service security implication in that it would lead to the modem hanging up the connection should the computer ever try to transmit the byte sequence "+++ATH0" in data mode. For any computer connected to the Internet through such a modem, this could be easily exploited by sending it a ping of death request containing the sequence "+++ATH0" in the payload. The computer operating system would automatically try to reply the sender with the same payload, immediately disconnecting itself from the Internet, as the modem would interpret the ICMP packet's data payload as a Hayes command. The same error would also trigger if, for example, the user of the computer ever tried to send an e-mail containing the aforementioned string.
Commands
The Hayes command set includes commands for various phone-line operations such as dialing and hanging-up. 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 an ampersand to denote those dedicated to new functionality. Hayes itself was forced to quickly introduce a 2400 baud model shortly after their 1200, and the command sets were identical as a time-saving method. Essentially by accident, this allowed users of existing 1200 baud modems to use the new Hayes 2400 models without changing their software. This re-inforced the use of the Hayes versions of these commands. Years later, the Telecommunications Industry Association /Electronic Industries Alliance raised the 2400-baud command set into a formal standard with the title Data Transmission Systems and Equipment - Serial Asynchronous Automatic Dialing and Control, TIA/EIA-602.
However, Hayes Communications were slow to release modems supporting higher speeds or compression, and three other companies led the way here — Microcom, U.S. Robotics and Telebit. Each of these three used its own additional command-sets instead of waiting for Hayes to lead the way. By the early-1990s, there were four major command sets in use, and a number of versions based on one of these. Things became simpler again during the widespread introduction of 14.4 and 28.8 kbit/s 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. Only one other command set has remained popular, the US Robotics set from their popular line of modems.
Description
The following text lists part of the Hayes command set, also called the AT commands: "AT" meaning 'attention'. Each command string is prefixed with "AT", and a number of discrete command can be concatenated after the "AT".The Hayes command set can subdivide into four groups:
- basic command set – A capital character followed by a digit. For example, M1.
- extended command set – An "&" and a capital character followed by a digit. This extends the basic command set. For example, &M1. Note that M1 is different from &M1.
- proprietary command set – Usually starting either with a backslash or with 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 represents a specific physical location in memory. Modems have small amounts of memory on board. The fourth set of commands serves for entering values into a particular register. For example, S7=60 instructs the modem to "Set register #7 to the value 60". Registers usually control aspects of the modem operation and are usually specific to a particular model.
When in data mode, an escape sequence can 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.
Syntactical definitions
The following syntactical definitions apply:-
Carriage return character, is the command line and result code terminator character, which value, in decimal ASCII between 0 and 255, is specified in register S3. The default value is 13. -
Linefeed character, is the character recognised as line feed character. Its value, in decimal ASCII between 0 and 255, is specified in register S4. The default value is 10. The line feed character is output after the carriage return character if verbose result codes are used ; otherwise, if numeric format result codes are used, it will not appear in the result codes. - <...> Name enclosed in angle brackets is a syntactical element. They do not appear in the command line.
- Optional subparameter of a command or an optional part of AT information response is enclosed in square brackets. Brackets themselves do not appear in the command line. When the subparameter is not given in AT commands which have a Read command, the new value equals its previous value. In AT commands which do not store the values of any of their subparameters, and so have not a Read command, which are called action type commands, the action should be done on the basis of the recommended default setting of the subparameter.
Modem initialization
AT&F&D2&C1S0=0X4
. Most modem software supported a user supplied initialization string, which was typically a long concatenated AT command which was sent to the modem upon launch. The V.250 specification requires all DCEs to accept a body of at least 40 characters of concatenated commands.Example session
The following represents two computers, computer A and computer B, both with modems attached, and the user controlling the modems with terminal-emulator software. Terminal-emulator software typically allows the user to send Hayes commands directly to the modem, and to see the responses. In this example, the user of computer A makes the modem dial the phone number of modem B at phone number 555-1234. After every command and response, there is a carriage return sent to complete the command.Modem A | Modem B | Comment |
ATDT15551234 | User at modem A issues a dial command: AT-Get the modem's ATtention; D-Dial; T-Touch-Tone; 15551234-Call this number | |
RING | Modem A begins dialing. Modem B's phone-line rings, and the modem reports the fact. | |
ATA | Computer at modem B issues answer command. | |
CONNECT | CONNECT | The modems connect, and both modems report "connect". Also, at this time, both modems will raise the DCD, or Data Carrier Detect signal, on the serial port. |
abcdef | abcdef | When the modems are connected, any characters typed at either side will appear on the other side. The person at computer A starts typing. The characters pass through the modem and appear on computer B's screen.. |
+++ | The person at computer B issues the modem escape command. | |
OK | The modem acknowledges it. | |
ATH | The person at computer B issues a hang up command. | |
NO CARRIER | OK | Both modems report that the connection has ended. Modem B responds "OK" as the expected result of the command; modem A says NO CARRIER to report that the remote side interrupted the connection. The modems on both sides drop their DCD signals as well. |
Compatibility
While the original Hayes command set represented a huge leap forward in modem-based communications, with time many problems set in, almost none of them due to Hayes per se:- Due to the lack of a written standard, other modem manufacturers just copied the external visible commands and the basic actions. This led to a wide variety of subtle differences in how modems changed from state to state, and 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 many different commands for different modems. This undermined the handy universality of the basic Hayes command set.
- Many Hayes compatible modems had serious quirks that made them effectively incompatible. For example, many modems required a pause of several seconds after receiving the "AT Z" reset command. Some modems required spaces between commands, while 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 data.
Autobaud
The Hayes command set facilitated automatic baud rate detection as "A" and "T" happen to have bit patterns that are very regular; "A" is "100 0001" and so has a 1 bit at the start and end and "T" is "101 0100" which has a pattern with every other bit set. Since the RS-232 interface transmits least significant bit first, the according line pattern with 8-N-1 is 01000001010001010101 which is used as syncword.The basic Hayes command set
The following commands are understood by virtually all modems supporting an AT command set, whether old or new.Command | Description | Comments |
A0 or A | Answer incoming call | |
A/ | Repeat last command | Do not preface with AT, do not follow with carriage return. Enter usually aborts. |
D | Dial | Dial the following number and then handshake 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 L - Dial last number |
E0 or E | No Echo | Will not echo commands to the computer |
E1 | Echo | Will echo commands to the computer |
H0 or H | Hook Status | On hook. Hangs up the phone, ending any call in progress. |
H1 | Hook status | Off hook. Picks up the phone line |
I0 to I9 | Inquiry, Information, or Interrogation | This command returns information about the model, such as its firmware or brand name. Each number returns one line of modem-specific information, or the word ERROR if the line is not defined. Today, Windows uses this for Plug-and-play detection of specific modem types. |
L0 or Ln | Speaker Loudness. Supported only by some modems with speakers. Modems lacking speakers, or with physical volume controls, or ones whose sound output is piped through the sound card will not support this command. | 0 turns off speaker, 1 to 3 are for increasing volumes. |
M0 or M | Speaker off, completely silent during dialing | M3 is also common, but different on many brands |
M1 | Speaker on until remote carrier detected | |
M2 | Speaker always on | |
O | Return Online | Returns the modem back to the normal connected state after being interrupted by the "+++" escape code. |
Q0 or Q | Quiet Mode | Off - Displays result codes, user sees command responses |
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 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, and query its value. Using ? on its own will query whichever register was most recently selected. |
Sn=r | 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, 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 | |
X0 or X | Smartmodem | Hayes Smartmodem 300 compatible result codes |
X1 | Usually adds connection speed to basic result codes | |
X2 | Usually adds dial tone detection | |
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, and usually also physically power-cycles the modem. Z0, Z1 etc. are for multiple stored profiles. &F is similar in that it returns to factory default settings on modems without NVRAM, but it does not reset the modem |
Note: a command string is terminated with a CR character
Although not part of the command set, a tilde character ~ is commonly used in modem command sequences. The ~ causes many applications to pause sending the command stream to the device, e.g. after a Reset. The ~' is not sent to the modem.
Modem S register definitions
V.250
The ITU-T established a standard in its V-Series Recommendations, V.25 ter, in 1995 in an attempt to establish a standard for the command set again. It was renamed V.250 in 1998 with an annex that was not concerning the Hayes command set renamed as V.251. A V.250 compliant modem implements the A, D, E, H, I, L, M, N, O, P, Q, T, V, X, Z, &C, &D, and &F commands in the way specified by the standard. It must also implement S registers and must use registers S0, S3, S4, S5, S6, S7, S8, and S10 for the purposes given in the standard. It also must implement any command beginning with the plus sign, "+" followed by any letter A to Z, only in accordance with ITU recommendations. Modem manufacturers are free to implement other commands and S-registers as they see fit, and may add options to standard commands.Leading characters | Includes commands related to |
+A | Call control issues, common, PSTN, ISDN, ITU-T Rec. X.25, switched digital |
+C | Digital Cellular extensions |
+D | Data Compression, ITU-T Rec. V.42 bis |
+E | Error Control, ITU-T Rec. V.42 |
+F | Facsimile, ITU-T Rec. T.30, etc. |
+G | Generic issues such as identity and capabilities |
+I | DTE-DCE Interface issues, ITU-T Rec. V.24, etc. |
+M | Modulation, ITU-T Rec. V.32 bis, etc. |
+P | PCM DCE commands, ITU-T Rec. V.92 |
+S | Switched or Simultaneous Data Types |
+T | Test issues |
+V | Voice extensions |
+W | Wireless extensions |
GSM
The ETSI GSM 07.07 specifies AT style commands for controlling a GSM phone or modem. The ETSI GSM 07.05 specifies AT style commands for managing the Short Message Service feature of GSM.Examples of GSM commands:
Command | Description |
AT+CPIN=1234 | Enter PIN code |
AT+CPWD="SC","old","new" | Change PIN code from 'old' to 'new' |
AT+CLCK="SC",0,"1234" | Remove PIN code |
AT&V | Status |
ATI | Status |
AT+COPS=? | List available networks 0-Unknown/2-Current/3-Forbidden, Longname, Shortname, Numerical-ID, "AcT" |
AT+CSQ | Get signal strength. Answer: +CSQ: |
ATD*99# | Dial access point |
AT+CGDCONT=1,"IP","access.point.name" | Defines PDP context |
GSM/3G modems typically support the ETSI GSM 07.07/3GPP TS 27.007 AT command set extensions, although how many commands are implemented varies.
Most USB modem vendors, such as Huawei, Sierra Wireless, Option, have also defined proprietary extensions for radio mode selection or similar. Some recent high speed modems provide a virtual Ethernet interface instead of using a Point-to-Point Protocol for the data connection because of performance reasons. The set-up requires vendor-specific AT command extensions. Sometimes the specifications for these extensions are openly available, other times the vendor requires an NDA for access to these.