Hayes modem AT command set
- Hayes AT command set, the history
- Data mode and command mode
- Basic, extended, proprietary and register commands
- Basic Hayes AT commands
Hayes AT command set, the history
Modems have been used since the beginning of computer history. The word modem is a combination of the words modulator and de-modulator and this typically defines what modem devices are doing. Digital data coming from a DTE, data terminal equipment is modulated in such a way that it can be sent over transmission lines. On the other side of the line a second modem demodulates the incoming data and forwards them.
The oldest modems were only capable of sending and receiving data. To establish a connection a secondary device like a dialer was needed. Sometimes connections were established manually by dialing the appropriate telephone number and the modem was switched on once the connection was present. This wasn’t problematic in the old days when computers were operated by skilled technicians and the costs of a separate dialer was insignificant compared to the costs of terminals, modems and mainframes. In the seventies small computers were entering the domestic market and costs and lack of technical knowledge slowly became an issue.
We are talking about the age when internet, tele-banking and other common communication applications as we know them now didn’t exist yet. The main reason for people to use a modem was to connect with BBSes, Bulletin Board Systems. Main computer systems operated by companies or volunteers where people could communicate with each other using message boards and up- and download software and utilities. Low-cost easy to use modems were necessary to make this possible. Ideally, those modems should be able to dial the desired phone numbers without interference of the user or an external dialer.
As can be seen in the RS232 port layout, the RS232 standard describes a secondary communication channel on the 25 pins DB25 connector that was originally projected to send control commands to the attached modem. This could include commands to dial a specific phone number. Unfortunately on the low-cost RS232 implementations present on the home computers in the seventies, that secondary communication channel wasn’t implemented. Therefore a method had to be defined to use the existing data channel to not only transfer data from one end to the other, but also control commands intended for the local modem only. Dennis Hayes came in 1977 with the solution. His Smartmodem used the single RS232 communication channel to the attached computer to transfer both control commands and data. Because every command started with AT of attention, the control language defined by Hayes soon became known as the Hayes AT command set. Because of its simplicity and low-cost implementation, the Hayes AT command set was soon implemented on modems of other manufacturers. As functionality and complexity of modems increased in time, so did the Hayes AT command language and soon every modem manufacturer implemented his own dialect. Nowadays the Hayes AT command set includes command for data, fax, voice and SMS communications.
Data mode and command mode
Dennis Hayes managed to use only one communication channel for his Smartmodem, by defining a data mode and a command mode. Switching from command mode to data mode was easy, a control command could be used for this. Switching back from data mode to command mode with in-band signalling was a little bit more tricky. One possibility would have been to use the default ASCII DLE data link escape character as a trigger to switch back from data mode to command mode. But this will give problems when binary data is transmitted as that byte value may well be present in the data transmitted. A binary data stream intended to be transmitted over the modem connection to another modem can consist of any combination of characters. Defining a specific byte sequence as trigger to switch from data mode to command mode could result in the modem to switch back to command mode every time when that specific sequence is detected, even if it was just by accident part of the regular data stream. The escape sequence to jump back to command mode was defined as “+++”, three plus signs. The chance that three plus signs within a data stream would trigger the switch was reduced by adding an additional rule: only when the “+++” data sequence was preceded and followed by one second of silence on the line, the modem would recognize it as an escape sequence. If additional data is sent from the attached computer to the modem within a second, the modem will assume that the three plus signs are part of a regular data stream and they will be transmitted to the other modem. In practice, the chance that three plus signs in a data stream are preceded and followed directly by a pause of at least one second is negligible.
Basic, extended, proprietary and register commands
The rules of the Hayes AT command language are quite simple. First of all there are some basic things to know:
- Every command starts with “AT” or “at”. The strings “aT” and “At” are invalid to start a command. The only exceptions of this rule are “+++” to switch from data mode to command mode and “A/” to repeat the previous command.
- Commands can be given in uppercase and lower case.
- Several commands can be combined in one command line.
- The length of a command line should be less than fourty characters.
- To allow manual editing, the backspace is recognized to delete the previous typed character in a command string.
- Every command starting with “AT” or “at” must be ended with ENTER.
- Telephone numbers my contain the characters “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “*”, “=”, “,”, “;”, “#”, “+” and “>”. All other characters in a telephone number are ignored.
- If a numerical parameter in a command is not entered, it is assumed to be zero.
- The ATZ command, used to reset the modem should be followed by a pause of at least two seconds before the next command is entered.
As said before, as soon as other manufacturers started to implement the Hayes AT command set in their modems, dialects started to occur. Dialects only add new commands to the existing AT command set, but in general do not change the original commands. This is possible by defining three levels of command sets within the modem, the basic command set, the extended command set and the proprietary command set.
The basic command set consists of all the necessary commands to use the modem. Basic commands can be recognized by the alphanumeric character directly following the “AT”. Extended commands are used for functionality not present on the first Hayes Smartmodem implementation. These commands are still considered standard and they are available on almost all modern modems. Extended commands are recognized by the ampersand “&” directly following the “AT”. Proprietary commands differ from one modem manufacturer to the other, and even between different models. Modem manufacturers use various characters after the “AT” to define their own proprietary commands. Often the backslash “\” and percent sign “%” are used, but there are other implementations.
To store values inside the modem, like the default timeout time to be used when dialing a telephone number, registers have been defined. Registers have a unique number. In a command string, registers are defined as “Sxxx”, where xxx is the specific register number. Register values can be stored, read and cleared from memory using basic AT commands.
Basic Hayes AT commands
- ATA, Anwer incoming call
ATA can be used answer an incoming call manually. Another modem must already try to connect to the modem and the line should be ringing. After the ATA command, the modem picks up the line, negotiates with the other modem about the data transfer rate and error correction settings and switches to data transfer mode when the negotiation succeeds. In case of success, the string “CONNECT” is returned, otherwise the returned string is “ERROR”. In the latter case the modem stays in command mode. The “CONNECT” string may be followed by text indicating the speed and protocol settings used for the session.
- ATB, Select communication standard
The original Hayes modems allowed to select the protocol to handshake at 300 and 1200 bps with the ATB command. Both CCITT and Bell protocols could be selected. Some other vendor added higher values and used the ATB command to limit the maximum negotiable connection speed. The command returns “OK”, if the protocol selection succeeds, otherwise the string “ERROR” is returned. Most modern modems ignore the ATB command and return the “OK” string for compatibility.
- B0 Select V32 mode/CCITT protocol
- B1 Select Bell 212A protocol
- ATE, Select local echo
Entered commands can be echoed back to the sender when the ATE command is used. Normally commands are not echoed back, but it can be useful for debugging purposes or when the modem is manually controlled via a terminal emulator program. Two parameters are possible. The command returns “OK” in normal cases and “ERROR” when a parameter other than 0 or 1 was specified.
- E0 Switch echo off
- E1 Switch echo on
- ATH, Hook control
The modem is equipped with its own telephone line interface. Just as with a normal telephone, the modem can go off-hook, connecting the interface with the line, or on-hook to disconnect. This is controlled with the ATH command. The digit following the H defines the requested hook mode. The command returns “OK” if a valid parameter was supplied and “ERROR” otherwise.
- H0 Go on-hook (disconnect)
- H1 Go off-hook (connect)
- ATL, Set speaker volume
Most modems are equipped with a speaker. This speaker can be used to monitor connection problems. The volume of the speaker is controlled by the ATL command. The digit following the L defines the required speaker volume. Several volume levels are possible. The command returns “OK” if the speaker could be set to the requested volume, and “ERROR” if the command fails.
- L0 Lowest speaker volume, or off
- L1 Low speaker volume
- L2 Medium speaker volume
- L3 Highest speaker volume
- ATM, Speaker control
In many cases the speaker is only necessary to monitor the dial and negotiation sequence of the modem. In other situations it is desired to switch the speaker on during the whole session, or have it switched off from the start. The ATM command can be used to select when the speaker should be working. The digit following the M defines the speaker mode. Four different modes are selectable. The command returns “OK” if the speaker mode setting succeeded, and “ERROR” otherwise.
- M0 Speaker always off
- M1 Speaker on until carrier detected
- M2 Speaker always on
- M3 Speaker on only while answering (not on all modems)
- ATQ, Quiet mode
When there will no processing of return codes from the modem,
- ATV, Verbose mode
The modem returns messages to the computer to indicate the return status of commands, interrupts like an incoming call and call progress. These messages can by either in English text, or numeric. When manual dialing, text messages are preferred, but with control from a program numeric messages may be less problematic to interpret. The ATV can be used to switch between text and numeric response messages. The digit following the V indicates the message type to be returned. The function returns “OK” when a valid parameter was supplied, and “ERROR” otherwise.
- V0 Numeric result codes
- V1 English text result codes (“OK”, “ERROR”, “CONNECT”, etc)
- ATX, Select call progress method
The procedure calling another modem and negotiating about the transfer parameters goes through different stages. The ATX command can be used to select which progress reports should be returned to the calling computer. The command returns “OK” when a valid parameter is supplied. Otherwise the string “ERROR” is returned. The following options are available.
- X0 Hayes smartmodem 300 compatible call progress: blind dial and no busy detect. “CONNECT” message when connection established.
- X1 Blind dial and no busy detect. The connection speed in bps is appended to the “CONNECT” string.
- X2 Dial tone detection, but no busy detection. The return string is “CONNECT”, followed by the connection speed in bps.
- X3 Blind dial, but busy detection. The return string is “CONNECT”, followed by the connection speed in bps.
- X4 Dial tone detection and busy tone detection. The return string is the connection speed in bps appended to the “CONNECT” string.
- ATZ, Reset modem
The modem can be reset to a default state with the ATZ command. The digit following the Z indicates to which state the modem should be reset. Following this command, a pause of at least two seconds is necessary to give the modem time to initialize its new state. When the reset command is issued, a pending communication session will be aborted and the line will go on-hook. The following reset states can be selected. These states are stored in non-volatile memory in the modem. Modems provide at least two stored profiles, but some modems have mode. The function returns “OK” if the profile exists, and “ERROR” otherwise.
- Z0 Restore stored profile 0
- Z1 Restore stored profile 1
Speak with authority; however, only expound on the obvious and proven facts.
SPARK'S THIRD RULE FOR MANAGERS