Controlling your Modem with AT Commands

Controlling your Modem with AT Commands


Issuing AT Commands

Getting Started with the Terminal Mode

With your modem installed, your computer powered ON, and your computer's communications software loaded in its terminal mode, you can enter commands to the modem.

Sample Hyper Terminal Mode display

If available in your communication's software, select the "terminal mode" (sometimes referred to as, "terminal emulation mode", "dumb terminal mode", "local mode", or "direct connect mode"). This mode allows you to send commands directly to the modem. Some software packages start immediately in the terminal mode as soon as you load the program.

Using AT Commands

When issued to the fax modem, AT commands direct the fax modem to dial, answer, hang up, and to perform many other communication tasks. Some of the most commonly used commands are:

AT (Attention). This is the command line prefix. (All the commands listed , except A/ and +++, must be preceded by the command AT). A Answer an incoming call D Dial the following phone number E Turn echo OFF H Hang up O Return to on-line state Z Reset the modem to the values stored in the N.V. Ram +++ Return to the Command State A/ Repeat last command (Do not precede this command with AT or follow it with <Enter>)

The Command Line

A Command line allows you to issue a number of commands at one time rather than issuing and waiting for the modem to react to each command separately. Here are a few rules you must follow when issuing a command line to the modem.

  • 1. Every command line must begin with the letters AT, (except the commands A/ and +++)
  • 2. You can group several commands on one line as long as the total line does not exceed 40 characters. Remember that "DT" and <Enter> each count as one character, (do not count spaces and the AT).
  • 3. Because all spaces are ignored in the command line, you may leave spaces between each command, and between each character of every command. You can also include punctuation's in telephone numbers, and type commands in either UPPER- or lowercase. For example, the following commands are identical:

    ATDT8005551234 < Enter > or

    atdt (800) 876-5555 < Enter >

  • 4. To cancel a dialing command in progress, press any key on the keyboard.
  • 5. If you make an error, backspace to erase it, and retype the characters correctly.
  • 6. To execute the command line, press the <Enter> or <Return> key on your keyboard.
Repeating a Command Line

If you want to repeat the last command line you entered, type the following command:

A/        (upper or lowercase A, followed by a slash)
  • Note: In this case you do not need to type AT first, nor do you press <Enter> at the end of the command line. This command comes in handy when you need to redial a number that got a busy signal.
Result Codes

When a command is issued, the screen will usually respond with a message. This message is called a "Result Code". It tells you the result of the command you've executed; whether the command has been executed, whether you have connected to another modem, whether the modem received a busy signal, and so forth.

Result codes can be displayed by either a number representing a result code or by verbal responses for a more descriptive code. Your modem has been defaulted to show the verbal response codes. However, you can alter the result code responses in the following ways:

  • 1. The Xn command instructs the modem to give you less detailed responses. The default is X4.
  • 2. The V0 command instructs the modem to respond with numerical (digits) instead of verbal result codes.
  • 3. The Q1 command disables generation of result codes.
  • 4.The W dial string modifier instructs the modem to wait for a DIAL tone before continuing dialing.
  • 5.The @ dial string modifier instructs the modem to include the NO ANSWER result code in the X4 mode.
Dialing with AT Commands

The Terminal mode allows you to instruct the modem to dial a remote modem by issuing the D command followed by the phone number. You can also include dial string modifiers in your command line to give the modem additional instructions. The following dial modifiers are available on most modems:

  • T Dial using DTMF tones
  • P Pulse/rotary dial (factory default)
  • , Pause
  • W Wait for dial tone
  • @ Wait for silence
  • ! Hookflash
  • ; Return to the Command Mode after dialing
  • Note: Download the complete AT command manual for more information on whether the commands are supported by your model.
Simple Dialing

To command the modem to dial a remote modem from an ordinary tone dialing telephone line, enter the dialing command followed by the phone number. For example, type the following command:

ATDT 876-5555 < Enter >
  • Note: For rotary/pulse dialing telephone systems you must use:
ATDP 876-5555 <Enter>Note: If all of your typed characters appear double (for example, you see AATTDD), you need to disable command echo by reconfiguring your communication software (refer to the software manual) or issuing the ATE0 <Enter> command. After you issue the dialing command you will hear the modem dialing and the remote telephone ringing. If the remote modem answers the call, the two modems will send high-pitched carrier tones to one another which establishes the transmission speed and other parameters for the data connection. This process is called handshaking.

If the call is answered, you should see the message, "CONNECT", followed by the connection speed. If the other phone line is busy, you will see "NO CARRIER" or "Busy" displayed (this is dependent upon the current X setting). If the other modem does not answer, you will see the message,"NO CARRIER".

After a connection has been established, with one of the "CONNECT" messages displayed, the modem is ready to immediately begin transmitting and receiving data. This may vary from typing messages to each other, sending or receiving files, logging on to an information service, or any other data communication task you wish to perform.

Manual Dialing Commands

If both your modem and the remote modem that you are connecting with have phones connected through the phone jacks on the modem, this mode will allow you to toggle between a voice connection and a data connection. This feature is invaluable if your trying to make adjustments to optimize your communications with the remote modem. After discussing what changes you want to make you can then release the line to the modem and switch back again if you need to discuss the further modifications.

Switching Between Voice and Data

To switch from a voice connection to a data connection, both you and the other party must have a computer with a modem. Communication software must be loaded and in the terminal mode (this may be referred as, "Dumb Terminal", "Terminal Emulation Mode", "Local Mode", "Direct Connect Mode", "On-line Manual" or something similar). Check your software communication manual if you can't locate this mode.

Switching From Voice to Data

You can make the initial call either by dialing your telephone manually or by letting the modem dial for you. When you have completed your voice conversation and want to switch to a data connection, type the following command:

ATX3D <Enter>This command instructs the modem to be the "originating modem". While you are issuing this command the other party should type the following command: ATA <Enter>This command instructs the modem to be the "answering modem". Either party may be the answering or originating modem, but, both parties can't be the originating or answering modem.

Both parties should now hang up their telephone handsets. If you don't hang up, data errors may occur. You will now hear the modems handshake and see the result code CONNECT along with the connection speed.

Switching From Data to Voice

To switch from a data connection to a voice connection, both parties would pick up their handsets, and either use the hang-up command of the software you are using or issue the Escape sequence command (+++) followed by the ATH command as soon as the modem responds OK to the Escape command. You should now hear the other party in your telephone handset.

Using the Modem to Establish a Voice Call

To use the modem as an auto-dialer you can either use software designed for this purpose or use regular communication software with a few modifications.

Add a record to the communication software you are using. In the phone number field, enter the voice telephone number followed by a semi- colon (;) and an H. The semicolon instructs the modem to return to the command mode after dialing the number. The H command then instructs the modem to hang-up releasing the line to your telephone.

Before selecting the record to dial, pick up the telephone handset (connected to the Phone Jack of the modem). You should hear the dial tone in the handset. Select the record to dial. You should now no longer hear the dial tone in the handset. After the modem dials the number, the modem will be returned to the command mode and then hung up. You should be able to hear the phone ringing in your handset.

Hanging Up

If you are using a communications program, use the "hang up" or "disconnect" command in the program to disconnect the call.

A method used with computers in the “dumb terminal mode” is to return to the Command State by typing an escape sequence. Typing three plus signs is the standard escape sequence,

+++(refer to Issuing Commands During the Data Connection), and to hang-up then type the "hang-up" command as follows: ATH <Enter>Dialing from a Business Phone System

When you dial from a business phone, you typically must instruct the modem to dial a number for an outside line, to wait for a dial tone, and then to dial the telephone number of the remote modem. A typical command line might look like this:

ATDT9,876-5555 <Enter>Here the modem dials 9 for an outside line, pauses to wait for a dial tone (the comma in the command line causes the pause), and then dials the number.

By default, the comma causes a two-second pause. However, you can create a longer or shorter pause by changing the value for register S8.

You can also create a longer pause by including several commas in a row in the command line. If there is no dial tone by the time the pause ends, the modem will go ahead and dial the number anyway, but the connection will not succeed.

A better way to dial would be to insert a W in the command line to instruct the modem to wait until it hears the dial tone (for a specific maximum amount of time). The command line would look like this:

ATD9W876-5555<Enter>Here the modem dials 9 for an outside line and then waits for a dial tone (the default maximum wait time varies from modem to modem, but the range is usually 30 to 50 seconds, but you can change this value in register S7). If no dial tone is detected in the specified time, the modem hangs up.
  • Note: Your office phone system must allow the use of a regular telephone (not a proprietary phone) to use your modem from your business.
Returning to the Command State After Dialing

Occasionally you may want the modem to dial a number and then to return to Command State to send additional commands before establishing a data connection. You will find this feature useful when dialing an electronic service such as telephone banking. You can dial the number of the bank, then after the call is answered, you can enter your access code.

To cause the modem to return to Command State after dialing, include a ; (semicolon) at the end of the command line.

For example, to dial a bank for electronic banking, you might type the following command:

ATDT 876-5555; <Enter>Here, the modem tone dials the number. If the remote modem answers, you see the OK Result Code, and can enter addition commands. For example, to instruct the modem to dial your access code or account number, you could enter the second command line as follows: ATDT 12345678 <Enter>If the connection is successful, you will see the CONNECT Result Code on your screen.

Transferring a Call with a Hookflash

The ! can be used in a dialing command to create a “hookflash”. During the hookflash, the modem hangs up for 1/2 second and then reconnects.

The following command line could be used to transfer a call to extension 333:

ATDT!333; H <Enter>Here the modem receives the tone dialing command, issues the hookflash, and then tone dials the extension. The semicolon returns the modem to Command State so it can hang up.

Waiting for Silence

Some services may answer your modems call with a prerecorded message of their own. In this case you would have to instruct the modem to wait until the message was over before proceeding with the data connection. You can do this with the @ dial modifier.

To instruct the modem to dial a number, listen for ringing, and then wait for up to fifty seconds for a 5 second silence (you can change the wait time with register S7) before proceeding you could use the following command line:

ATDT876-5555@ 5678 <Enter>Here you instruct the modem to tone dial the number and then, if it hears ringing, to wait up to fifty seconds for 5 seconds of silence before dialing the remaining digits (this could be an extension number, a password, or an account number).

Dialing a Stored Phone Number

Your modem can dial one of up to four previously stored telephone numbers (identified as 0-3) of up to 33 digits each. This feature is useful for connecting to a frequently called remote modem without your having to dial the digits individually.

You can store the phone number in the nonvolatile RAM with the &Zn=x command. The n refers to which of the four (0-3) memory locations you want, and the x is the phone number. To store the phone number 876-5555 as the 3rd stored number, type the following command:

AT&Z3 = 8765555 <Enter>Here the modem is instructed to store the telephone number as stored number #3. Once stored, the number is retained in the modems nonvolatile memory until you change it. The phone number remains stored even when power to the modem is turned OFF.

To dial a previously stored phone number you would use the s=n dial string modifier, (n refers to which of the four stored phone numbers you wish to have dialed). To dial stored phone number 3, you would type the following command:

ATDs=3 <Enter>The s=n can appear anywhere in the dialing command. For example, you might want to store a special access code or password that follows the phone number. Your command line might look like this: ATDT8765555, s = 1 <Enter>In the above example you command dialing the phone number. The modem then pauses for a set length of time (the “comma” forces this pause) and then dials a previously stored access code (the result of the s=1 dial modifier).

Do not confuse the s = n dial string modifier with the S command used to read or change the value of S-Registers.

Answer Mode

Answering a Call

When the modem is in the data mode, Auto-Answer will answer an incoming call provided the computer is on and your software is properly loaded.

  • Note: Your modem is not factory set to Auto-Answer telephone calls.
You can enable the Auto-Answer mode by setting register S0 to one or greater. Your terminal or computer must be in the On-Line mode with its DTR signal true or the &D0 command (DTR forced ON) must have been issued. See the discussions covering Selecting the Number of Rings and Disabling Auto-Answer.

When the modem answers the call, it sends a high-pitched carrier tone to the modem on the other end, which begins the handshaking process.

After handshaking, you will see one of the CONNECT result code messages on your screen, and the data connection will begin.

Selecting the Number of Rings

Register S0 allows you to select the number of rings after which the modem will Auto-Answer. For example, to instruct the modem to answer after four rings, type the following command:

ATS0=4 <Enter>Disabling Auto-Answer

If you want to disable the Auto-Answer feature (perhaps you will be away from your phone for a while), you can do so by setting register S0 to 0.) If you are using communications software, and it is programmed to Auto-Answer, it will do so regardless of the modems settings.

  • Note: The modem can answer a call even if Auto-Answer is disabled. Your computer must be turned ON, your computer's software loaded, and you must be in the terminal mode. When you hear the telephone ring, type the command ATA <Enter>. The modem will answer the call.
Sending and Receiving Files

You can use your modem, your computer and communications software to transmit (upload) and receive (download) files. These processes are handled through your communications software. See your communications software manual for more information.

Issuing Commands During the Data Connection

The modem has two operational states: Command State and Data State. When you first turn your terminal ON, or load your computer's communications software, and start giving commands to the modem, the modem is in Command State. However, once you make a connection with another modem and start passing information over the telephone lines, you are in the Data State and can no longer issue AT modem commands.

If your connection with the other computer is broken for any reason, you will automatically return to Command State so that you can issue new commands. However, you may want to return to Command State temporarily without losing your data connection (e.g. to change a communications parameter). The modem provides a special Escape Code that lets you do this.

Using the Escape Code

To return to Command State during a data connection, wait for one second of inactivity, and then quickly type three pluses (+++).

After one second of inactivity, you will see OK on the screen. You have returned to the Command State and can issue commands, but you have not lost your data connection.

Resuming the Data Connection

When you are in the Command State and want to resume the data connection, type the following command:

ATO <Enter>You will see the CONNECT result code on the screen and your data connection will continue.

Setting Communications Parameters

Whenever you communicate via modem you use certain settings that establish agreements between the two modems. These settings are called communication parameters and cover such items as baud rate, parity, character length, and the number of stop bits.

When you are using a computer, communication parameters are set and changed by your communication software. In order to establish a data connection, your communication parameters must match those of the remote modem.

You may find that you can communicate perfectly without changing your software settings. This can be because your terminal or computer software program uses common default settings which may be the same as those of the remote modem. However, if you experience difficulty, you may have to change your communication parameters. The most common setting are either are 7 data bits, Even parity, and 1 stop bit (7E1) or 8 data bits, No parity, and 1 stop bit (8N1).

The Factory Profile

The factory profile is permanently stored in your modem. It cannot be changed like the stored profiles can. The factory settings may not be what the software expects, but this is a good starting point for all Initialization strings. This will ensure that the modem is set correctly without sending every command that the modem supports.

You can always return to these factory settings by issuing the following command:

AT&F <Enter>You can return to the factory default settings, and then store them into the modems nonvolatile ram, (if supported in your model), for use when your modem is turned on or reset, by issuing either of the following commands: AT&F&W0 <Enter> (Stored profile #0 = factory defaults) orAT&F&W1 <Enter> (Stored profile #1 = factory defaults)Note: Refer to Everything you wanted to know about INITialization Strings, but were afraid to ask for information on INITialization strings. The Active Profile

The active profile contains the settings currently in effect. When you turn your modem on, or reset it, the modem reads its nonvolatile ram, if nonvolatile ram is supported in your model, and makes the active profile the same as one off the stored profiles. Normally, this will be stored profile #0, but exactly which stored profile is used is determined by the &Yn command. If nonvolatile ram is not supported by your model the active profile will be the same as the Factory Profile.

When you choose to store an active profile into the modems nonvolatile memory, the chosen stored profile is made the same as the current active profile.

The Stored Profile(s)

Two stored profiles are stored in the modems nonvolatile memory. When you turn your computer and modem off, or reset the modem, you do not change or lose either stored profile. When you turn your modem on, or reset it with the Zn command, the modem reads its nonvolatile memory, and makes the active profile the same as one of the stored profiles.

The stored profile used when you turn on the modem is determined by the &Yn command. &Y or &Y0 (the factory default setting) cause stored profile #0 to be used when the modem is turned on. &Y1 causes stored profile #1 to be used when the modem is turned on.

If you want to change one of the stored profiles to match the current active profile, you would use one of the following commands:

AT&W0 <Enter>(Stored profile #0 = current profile)orAT&W1 <Enter> (Stored profile #1 = current profile)Note: Not all parameters may be stored in the modems nonvolatile ram. Refer to the AT command manual for your model to determine which values may be stored. Viewing the Stored and Active Profile(s)

You may wonder "What's in my two stored profiles?" or "Just what is my active profile?". The &V command provides you with a "view" of your profiles. You must be in the "Terminal Mode" to be able to send the &V command to your modem. The &V command causes your modem to display a list of AT commands and S-Register settings currently in effect (Active Profile) and both stored profiles. Some models may also have a &V1 and &V2 command that will display other useful information.

Copyright@2000 Zoltrix International Limited
Last updated on May 06, 1999
Copyright@2000 Zoltrix International Limited
Last updated on May 06, 1999
Last updated on May 06, 1999
个人分类: 摘抄
想对作者说点什么? 我来说一句