Modem Commands AT Commands
The now-famous AT command set first appeared in the 300-baud Hayes Smartmodem, a name coined and trademarked by Hayes Microcomputer Products, Inc. The Smartmodem worked in two distinct modes:
♦ Command mode: Characters sent from the PC (DTE) are interpreted as commands for the modem.
♦ Online mode: After receiving a dial command and establishing a connection, the modem sends all received data out on the phone lines.
The Hayes Smartmodem commands start with the characters AT (for attention). The initial command set included those to dial a number, turn the modem's speaker on or off, and set the modem to answer an incoming call.
Modern manufacturers have widely copied the AT command system, making it a de facto standard. Although virtually all modems use a core command set, each modem manufacturer has its own proprietary commands that control some of the exotic and advanced features of the modem.
The AT Command Line
I have found it very helpful to know at least a few of the AT commands for controlling a modem. Although many communications programs hide the details of the AT commands, you can end up in a situation in which the communications software is primitive — all the software does is send the other modem whatever you type. In such situations, you can enter AT commands to set up the modem, dial out, and establish a connection. The following sections briefly cover the AT command set.
As the name implies, each command in the AT command set starts with the letters AT. Following these letters, you can enter one or more valid commands and end the command line with a carriage return (press Enter on the PC's keyboard). Thus, the command line has the following format:
In the preceding line of code, [command1] and [command2] denote optional commands, each of which has appropriate arguments. The ending <CR> is a required carriage return (the Enter key).
Suppose that you want to use the following commands:
♦ The E command with an argument of 1 to force the modem to echo the commands
♦ The V command with 1 as the argument to make the modem provide verbose result codes (instead of numeric codes)
You can send these commands to the modem with the following AT command line:
ATE1V1
As with any AT command line, of course, you have to end this command by pressing Enter. If you enter this command through a communications software package, you see that the modem replies with the string OK.
All modems accept at least 40 characters per command line, in which the character count includes the AT and the final carriage return. Many modems, however, can accept up to 255 characters on an AT command line.
If an internal modem stops responding to the AT commands, you may have to shut down the system and power it off to reset the modem.
The A/ Command
The A/ command is an exception to the AT command syntax. If you enter A/ as the only command on a line by itself (no need to press Enter), the modem immediately repeats the last command line it has received.
Configuration Commands
These commands specify how the modem should operate and how it responds to commands. Following are some useful configuration commands:
♦ Echo commands: ATE1 causes the modem to display a command as you type it; ATE0 disables the display of the command.
♦ Speaker volume: The ATLn (n being a number between 0 and 3) command sets the volume of the modem's built-in speaker. ATL0 and ATL1 set the volume to low, ATL2 sets it to medium, and ATL3 sets it to high.
♦ Speaker control: ATMn (n being a number between 0 and 2) controls whether and when the modem's speaker is turned on. ATM0 turns the speaker off, ATM1 turns it on until a call is established, and ATM2 turns it on always.
♦ Quiet mode: When quiet mode is enabled, the modem does not acknowledge commands or report call status. ATQ0 disables quiet mode and causes the modem to respond to commands and show call status. ATQ1 enables quiet mode.
♦ Verbose mode: When verbose mode is enabled, the modem acknowledges commands and reports call status with words. Otherwise, it responds with numeric codes (which may be more suitable for communications software than for humans). The ATV1 command turns on verbose mode; ATV0 turns it off. A typical modem generates the nine responses listed in Table E-3.
Table E-3: Responses" from a Typical Modem
|
0 |
OK |
|
1 |
CONNECT |
|
2 |
RING |
|
3 |
NO CARRIER |
|
4 |
ERROR |
|
5 |
CONNECT 1200 |
|
6 |
NO DIALTONE |
|
7 |
BUSY |
|
8 |
NO ANSWER |
"Most modems include several other responses for reporting successful connections at higher data rates.
"Most modems include several other responses for reporting successful connections at higher data rates.
♦ Result code selection: The ATXn command selects the type of reports the modem should send back. The argument n can be one of the following:
0 CONNECT
1 CONNECT bits-per-sec
2 CONNECTbits-per-sec, NODIALTONE
3 CONNECTbits-per-sec, BUSY
4 CONNECTbits-per-sec, NO DIALTONE, BUSY
♦ View stored profiles: The AT&V command causes the modem to display the current values of a selected set of configuration parameters and the values of internal registers. Some modems have nonvolatile memory to store groups of settings, known as profiles. On such modems, AT&V displays the stored profiles.
Action Commands
Each action command causes the modem to perform some action immediately. The most important action command is the dial command: ATDTnum6er. Two other useful action commands are ATZn and AT&Fn, which reset the modem's configuration. Following are some of the important action commands:
♦ Pulse dial: The ATDPnum6er command causes the modem to use the pulse-dialing system to dial a specified phone number. The pulse-dialing system was used by rotary telephones. Nowadays, you typically use the ATDT command to dial a number by using the tone-dialing system.
♦ Tone dial: Use the ATDTnum6er command to dial a specified phone number by using the tone-dialing system. To dial the number 555-1234, for example, use the command ATDT5 55-1234. You should enter whatever other digits you may need to dial the number you want to reach. If you need to dial 9 for an outside line, simply use ATDT9.555-1234. The comma introduces a slight pause (typically, two seconds), which may be necessary to get an outside line.
♦ Dial last number: The ATDL command causes the modem to execute the last dial command.
♦ Hook control: The ATH command simulates lifting or putting down the handset of a regular telephone. ATH0 hangs up the phone; ATH1 makes the modem go online (as though you have picked up the handset).
♦ Answer call: Use the ATA command to make the modem answer the phone. You can put the modem in answer mode (by setting register S0 — a storage area in the modem — to a nonzero value), so that it answers the phone when someone calls. With the ATA command, you can force the modem to answer the phone even if register S0 is set to 0 (which means the modem won't answer the phone).
♦ Return to online: The ATO command returns the modem to online mode. Use this command after you press +++ (rapidly enter three plus signs in sequence with some pause before and after the sequence) to take the modem offline.
♦ Software reset: If the modem stores configuration profiles in nonvolatile memory, you can recall one of the configuration profiles with the ATZn command (n being the number of the configuration profile). If you enter ATZ without any argument, the modem is reset. The ATZ command terminates any existing connection.
♦ Factory-default setting: The AT&F command causes the modem to restore the factory-default settings. Some modems take a numeric argument with AT&F; consult your modem's documentation for more information on the meaning of the numeric arguments.
The ATSr=n Commands
In addition to the AT command set, Hayes Smartmodem pioneered the use of internal modem registers to configure the modem. All current modems have registers, called the S registers, that control many aspects of the modem (including features that may be unique to a specific brand of modem).
A typical modem has anywhere from 30 to 60 S registers, denoted by S0, S1, S2, and so on. The ATSr=n command sets the S register numbered r to the value n. To view the current contents of the S register numbered r, use the ATSr? command.
Register S0, for example, contains the number of rings after which the modem answers the phone. When S0 is 0, the modem does not answer the phone at all. The following listing shows how you might query and set the S0 register with the ATS command:
ATS0? 000 OK
ATS0=1 OK
ATS0? 001
The exact set of S registers varies from one brand of modem to another, but most modems seem to provide and interpret the following 13 S registers consistently, as follows:
♦ S0, ring to answer on: The number of rings after which the modem answers the phone. When S0 is 0, the modem does not answer the phone.
♦ S1, counts number of rings: The count of incoming rings. When S1 equals S0, the modem answers the phone (assuming that SO is nonzero). The modem resets S1 to 0 a few seconds after the last ring.
♦ S2, escape code character: The character used as the escape sequence to switch the modem from online mode to command mode. The default value is 43, which is the ASCII code for the plus (+) character. To go from online mode to command mode, enter this escape character three times in rapid succession.
♦ S3, carriage-return character: The ASCII code of the character used as the carriage return (this character terminates the AT command lines). The default value is 13.
♦ S4, line-feed character: The ASCII code of the character used as the line-feed character when the modem generates word responses to commands. The default value is 10.
♦ S5, backspace character: The ASCII code of the character used as the backspace. The modem echoes this character to implement the "erase preceding character" function. The default value is 8.
♦ S6, wait time for dial tone (seconds): The number of seconds to wait before dialing the first digit in a dial command. The default value is 2.
♦ S7, wait time for carrier (seconds): The number of seconds the modem waits for a carrier. If the modem does not detect a carrier after waiting for this many seconds, it displays the NO CARRIER message. The default value depends on the modem. Typically it will be anywhere from 30 to 60.
♦ S8, comma time (seconds): The number of seconds to pause when the modem finds a comma in the phone number to dial. The default value is 2.
♦ S9, carrier detect time (tenths of a second): The amount of time, in tenths of a second, that the carrier must be present before the modem declares that a carrier has been detected. The default value is 6, which means the carrier must be present for 0.6 seconds before the modem detects it.
♦ S10, carrier loss time (tenths of a second): The amount of time, in tenths of a second, that the carrier must be lost before the modem disconnects. The default value is anywhere from 7 to 15, which means the carrier must be lost for 0.7 to 1.5 seconds before the modem disconnects.
♦ S11, dial-tone spacing (milliseconds): The duration of each dial tone and the spacing between adjacent tones. The default value is typically somewhere between 50 and 100 milliseconds (50 is considered the minimum necessary for dial tones to be recognized by the phone system).
♦ S12, escape sequence guard time (fiftieths of a second): The amount of guard time, in fiftieths of a second, that must occur before and after the escape-code sequence (the default sequence is +++) that switches the modem from online mode to command mode. The default value is 50, which means the guard time is one second.
Online Help
In response to the AT$ command, U.S. Robotics modems display online help information on the basic modem command sets. You'll find the help information instructive because it shows you the breadth of commands that a typical modem accepts. You can enter the command in a serial communication program such as Minicom, which I describe briefly later in the "Dialing Out with a Communication Program" section of this appendix.
Was this article helpful?