Communication; connectivity; flow of information; following orders. These are very important issues to everyone these days. Making sure that your intent is carried out correctly is espe- cially important and difficult when dealing with computers. This is because computers are SO stupid. It's fact. A computer cannot read between the lines or take a hint. You have to tell them what you want them to do and exactly HOW you want it done. If you assume that the computer will understand what you mean, nine times out of ten you won't get what you want.
This is also true when dealing with computer peripherals in general, and modems specifically. Nearly every peripheral device you can connect to your computer has some sort of command set that the experienced person can use to control the device very explicitly to achieve the desired effect. Most modems today use the command set originally introduced by the Hayes company for its modems. This command set is relatively simple and flexible enough to allow you to control your communications session com- pletely. Since the time the Hayes commands were originally con- ceived, modems have changed considerably. This has necessitated changes to the commands to keep pace with technology. The command set has evolved to include nearly 60 different commands.
In this, my third article on modems, I want to detail some of the most commonly used commands. I want to give you an idea of what the Hayes command set can do for you and under what circum- stances you would want to use them.
First, an introduction. All but two of the Hayes commands are prefaced with the letters AT. (See Figure 1,Hayes AT Command Quick Reference.) Most of the commands consist of a letter and number combination. The letter specifies the function or property to modify and the number defines the new value. Modems that comply with the Hayes standard have a set of internal registers that store information about how the modem should conduct a communications session and about the progress of the current session. You can directly control most of the features of the modem by setting or clearing bits in the proper register. Howev- er, there is usually an AT command that will do it for you much more easily.
Commands are sent to the modem from the computer along the same path as data, so there has to be a way to tell the modem that what you're sending it is not to be passed along, but to be used internally. When you first power up a modem, it's normally ready to listen to your commands. Which simply means, it's in Command Mode. The modem will automatically switch to On-Line Mode when a connection with another modem is established. If you need to send commands to the modem while it's in On-Line Mode, you can get it back to Command Mode by sending it what is called an escape sequence. The default escape sequence is +++, that is, three plus signs. These must be followed by a pause for approximately two seconds. You have just learned the first command that does not begin with AT.
If you forced the modem into Command Mode during a session, you'll want to return to On-Line Mode as soon as you've finished sending your commands. To do this, send ATO (the letter O, not the number 0) to the modem and it will return to On-Line Mode. Remember, when the modem is in On-Line Mode, it will not recog- nize any commands you may try to send it. Likewise, while it's in Command Mode, it will not pass data. It will, however, maintain any connection that existed before it went into Command Mode.
I've been blithely talking about sending commands to the modem, but if you're new to this kind of thing, you must be scratching your head and saying, "That's all very well, but HOW do I send stuff to the modem?"
There are actually a number of ways to do it, but most of them are fairly tedious. The simplest, most straightforward way is from the DOS prompt using the COPY command. "Hunh? The COPY command?!" That's right! If you want to send an escape sequence to a modem connected to COM2, for example, it would look some- thing like this: C:\>copy +++ com2 +++ ^Z
If you want to send a number of commands or try some fancy stuff, this would get tiresome. The next best way is to use your communications software. Most software has what is called termi- nal mode, - Procomm defaults to it. Usually, it just looks like a blank screen. From this screen, you should be able to type in the commands you want, and they'll automatically be sent to the modem for you. Don't forget to end each command sequence by hitting Enter.
Now you know how to recognize a Hayes command, how to send one to the modem and how to shift between On-Line and Command Modes. "But," you ask, "why do I want to do all this?" That's a good question. The answer is: you probably don't.
"Hunh? Then why are you telling me all this junk?" As I said in my first two articles, most modems will work with most communica- tions software to talk to most other systems most of the time. This is for those rare occasions when something goes wrong or when you want to do something special. It will also help you understand all those arcane options in the setup and configura- tion sections of your communications software. If you have a good communications program, and you configure it correctly, it will send the appropriate commands at the appropriate times.
The most common occasion for which you will need to be familiar with the Hayes commands is when your communications program asks you for the modem initialization string. If your setup program asked you for what brand of modem you have and you were able to select the correct one, you shouldn't have to change the default init string. If you see weird things happening, though, you may need to make some modifications. The only way to know that what you're doing is correct, is to read both the modem manual and the manual for your communications software very carefully. The reason for this is that if something isn't working correctly, it's probably because either the modem or the software or both do not comply with the standard. The only way to find out what they really expect is to go into the documentation. Having said that, I will now mention a few of the more commonly seen commands.
Of course, the whole point of using a modem is to connect to another computer via a phone line. The only way this can happen is if one computer calls the other. So the first command we'll look at is the dial command, or ATD. ATD is also one of the most complex, because there are any number of modifiers that can be used to connect in the exact way that you want. The first is either T or P, for Tone or Pulse. These days, it's unlikely that you will want to use Pulse dialing, but you may be in a foreign country where Touch Tone service hasn't been implemented yet. The second option is the number you want to dial. If you're calling from a normal non-business phone line, this is usually all you really need, so your full dialing command would look like: ATDT4451121.
You can insert spaces and the usual punctuation found with phone numbers. If the modem doesn't recognize the character, it's ignored. So you could have entered: ATDT 1 (804) 445-1121.
If you're using a phone that's on an exchange, that is, one which you need to dial a special code to get an outside line and then wait for the dial tone, you can insert a special pause character, the comma (,). The comma usually defaults to a pause of two seconds. While normally this is sufficient, some systems may take longer or may only give you a dial tone under the right circumstances. In that case, you can use the W modifier to tell the modem to wait until it gets a dial tone. If no dial tone is received, the call will terminate. This is particularly useful if you're trying to dial on a DSN line, for example. It might look something like this: ATDT 8 W 565-1121.
There are other modifiers for the dial command, but these are left as an exercise for the reader, as the saying goes.
The next two commands we'll look at control what you will hear during your session. Most modems have some sort of speaker so that you can monitor the progress of the call. If yours doesn't, then neither of these commands will be supported. The commands are ATM and ATL. ATL controls the volume of the speaker and requires a numeric modifier between 0 and 3 (off, soft, medium, loud). This is highly variable among manufacturers, so check your manual. What you want it set to will depend on your work environ- ment (ambient noise), how blocked the speaker is, and how good a speaker it is. Some modems have a volume knob so you can adjust it manually. If yours is one, it probably will not support the ATL command.
The ATM command determines when the speaker is on. ATM also takes a number between 0 and 3, where 0 = speaker always off, 1 = speaker on until a connection is achieved, 2 = speaker always on and 3 = speaker on from the end of dialing until a connection is achieved. If you work in a relatively quiet office, and you never have any problems making a connection, you may want to set ATM0 so as not to disturb your coworkers. If, on the other hand, you're calling a number that might be answered by a person and you have a very noisy work environment, you might want to set ATL3M2 so you can hear if a person answers and pick up the phone yourself. This example brings up another point about the Hayes commands. You can put multiple commands on the same line and prefix them all with AT. This is how you would enter the modem init string.
The next four commands control what you see on screen during a session. They are ATE, ATQ, ATV and ATX. ATE0 means don't echo commands to the screen; ATE1 means DO echo commands to the screen. Which you want again will depend on your needs. If you're having no problems with your connections, ATE0 provides a less cluttered screen. However, if you're experimenting with different strings, you may want to have them appear so you can follow the action. Also, if you're entering them manually and your terminal mode is full duplex, this is the only way to see what you typed.
ATQ0 means to display result codes; ATQ1 means don't display result codes. I'll go more into result codes in a little bit. ATV0 means use numeric result codes; ATV1 means use verbal result codes. Lastly ATX controls how "intelligent" your modem is. That is, what events it will recognize and report back to you and your software. These last two are especially important, because if they do not match what your software expects, it will never understand that the modem achieved a proper connection. Because different modems have different capabilities, the values for ATX that your modem supports and what they mean may vary widely from modem to modem. In general, the values range between 0 and 4, with ATX4 being the most intelligent.
Result codes will be even more specific than any of the other commands and features we've discussed so far. A typical list might look like the one that follows this article.
My modem supports a host of others, the majority of which are connect messages for the various speeds it supports (up to and including 57,600 bps). Yours may not even support what I've listed here, but don't worry about it. The important thing is that your modem and your software speak the same language.
These are, of course, just a few of the commands available. There are commands for viewing and manipulating the registers directly, extended commands to control details of the protocol between the modem and the computer, and special commands for controlling MNP, v.32, and v.42 options. The older your modem is, the less likely it is that it will support all these. The newer your modem, the more likely that you will need, or at least want, to learn to use the commands directly to control your modem. This is particularly true if your software is old (or cheap) and therefore doesn't support all the features available on newer modems. A little study in the manuals can provide you with a more efficient and productive modem.
Figure 1 Hayes AT Command Quick Reference AT Basic Command Set +++ Escape; go to Command Mode. A/ Re-execute command ATA Answer ATBn Select CCITT or Bell Mode ATCn Carrier Control ATDn Dial ATE Command Echo ATFn On-Line State Character Echo ATHn Switch Hook Control ATIn OEM Identification ATLn Speaker Volume ATMn Speaker Control ATNn Modulation Handshake ATOn Return to the On-Line State ATPSet Pulse-Dial as the Default ATQn Result Code Display ATSn? Reading S-Register(s) ATSn=x Writing to S-Register(s) ATTSet Tone-Dial as the Default ATVn Result Code Form (Message Control) ATWn Negotiation Progress Reporting ATXn Extended Result Codes ATYn Control Long Space Disconnect ATZn Hardware Reset
AT Extended Command Set AT&Cn DCD Option AT&Dn DTR Option AT&F Restore Factory Configuration AT&Gn Set Guard Tone AT&Jn Telephone Jack Selection AT&Kn DTE/Modem Flow Control AT&Ln Line Type AT&Mn Communication Mode AT&Pn Dial Pulse Ratio AT&Qn Communication Mode AT&Rn RTS/CTS Option AT&Sn DSR Option AT&Tn Test and Diagnostic AT&V View Current Configuration and User Profiles AT&Xn Clock Source Selection
MNP (v.32/v.32bis) Operation AT\An Maximum MNP Block Size AT\Bn Transmit Break AT\E Optimize Echo Cancellation AT\Gn Modem to Modem Flow Control AT\Kn Break Control AT\Ln MNP Block Transfer Control AT\Nn Operation Mode Control AT\O Originate Reliable Link Control AT\Tn Inactivity Timer Control AT\U Accept Reliable Mode Control AT\Y Switch to Reliable Mode AT\Z Switch to Normal Mode
v.42/v.42bis Operation AT%Cn Compression Control AT%Dn Set Dictionary Size (v.42bis) AT%En Enable/Disable Auto-Retrain AT%L Report Received Signal Level AT%Mn Set One/Two-Way Mode (v.42bis) AT%P Clear v.42bis Encoder Dictionary AT%Q Report Line Signal Quality AT%Sn Set Maximum String Length (v.42bis)
S- Register Quick Reference S0 Auto-answer S1 Count incoming rings S2 Escape char value S3 Carriage return character S4 Line feed char S5 Backspace char S6 Wait for dialtone S7 Wait for carrier S8 Pause time for dial delay S9 Carrier Detect response time S10 Carrier loss time S11 Tone dial speed S12 Esacpe code guard time S13 Reserved S14 Bit-mapped registers S15 Reserved S16 Bit-mapped test options S17 Reserved S18 Test timer S19 Reserved S20 Reserved S21 Bit-mapped registers S22 Bit-mapped registers S23 Bit-mapped registers S24 Reserved S25 Asynchronous DTR delay S26 RTS to CTS delay interval S28-29 Reserved S30 Inactivity Timer S31-35 Reserved S36 MNP/V.42 negotiation failure treatment S37 Line speed S38 MNP delay before forced disconnect S39 Reserved S40 Bit-mapped MNP registers S41 Bit-mapped MNP registers S42-45 Unused S46 MNP/V.42 protocol selection S47 Unused S48 V.42 negotiation action S49 Speed buffer lower limit S50 Speed buffer lower limit S51-81 Unused S82 Break handling option S83-85 Unused S86 Connection failure cause code S87-90 Unused S91 Programmable transmit level S92-94 Unused S95 MNP/V.42 extended result codes enabled (bitmapped)
Typical Result Codes Numeric Verbal Description 0 OK The last command sent to the modem was processed correctly. 1 CONNECT The modem achieved a connection at 300 bps. 2 RING The modem detected an incoming call. 3 NO CARRIER The modem could not make a connection or lost a connection due to the absence of the carrier signal. 4 ERROR An error has occurred; usually a bad command. 5 CONNECT 1200 The modem has achieved a connection at 1200bps. 6 NO DIAL TONE The modem did not detect a dialtone. 7 BUSY The modem dialed but got a busy signal.
About the Author: LT Buckley holds a BSE in Computer Science Engineering and is currently in charge of the Fleet ADP Support Team at NCTAMS LANT. He and his team can be reached at (804) 445-1105; DSN 565-1105.