ATコマンドの使い方

The AT Command set is named after a functional artifact of the original Hayes Smartmodems operation. On these modems, the modem would automatically adjust the DTE baud rate (the speed that bits move between the modem and the local computer or terminal) by watching for a pattern of ones and zeros that could be consistently stretched or compressed into representing the ASCII code for the letter "A", followed by the letter "T". The sequence of A followed by T is sometimes called "ATtention".


"Auto-bauding", which is the technique of looking for a specific sequence of bits and determining the senders speed based on how much the expected bit sequence timing must be stretched or compressed on reception (much like playing an audio recording faster or slower until you can understand it), can be traced back to the Digital Equipment Corporation DECSystem-10 systems of the early 1970s, which used the ASCII code [CONTROL]-C to determine serial communication speed of the DTE device, which could be anything between 75 and 9600bps. The reception of this character would also request a login prompt from the operating system, which would be returned at the computed DTE rate.


In AT compatible modems, following the computation of the possibly-correct baud rate by trying to get the received pattern of voltage transitions to align with one of the supported baud rates and the result looks like the ASCII code for the letter "A" (uppercase or lowercase), the tentatively identified speed would be verified by correctly reading the letter "T" at that speed.


If the "T" was correctly received with no framing errors, subsequent characters following the "T" are stored in the modem until an ASCII carriage return character (0x0d) is received, at which point the received characters are executed as commands to the modems Command Mode. (There are two special commands that do not start with "AT", but all the others do.)


During Command Mode, the ASCII backspace character (0x08) is normally accepted to erase the most recently received non-erase character from the command buffer. The size of the command buffer varies by modem, but the traditional size limit is 40 characters.


On reception of a carriage return, any commands that were sent to the modem would be executed in the order received (from left to right), up until a syntax or mode error is detected, or a command fails, or the maximum command length is reached, whichever occurs first. If no errors are encountered and all commands are performed, the modem will return a Result Code of "OK" or "0", depending on whether numeric or text responses have been previously selected.


If any commands are encountered that are invalid or not legal at this time, the result code "ERROR" or "4" could be returned. Certain commands can result in several other result codes which may mean that the command succeeded or failed. For example, a Dial command could return a "BUSY" or "7" Result Code, which indicate that the modem could not successfully reach the called party, while the same Dial command could also return a "CONNECT" or "1" Result Code, indicating that carrier has been successfully established to the remote modem. Result Codes are discussed in more detail later.


AT commands all start with a letter, although some commands use the ampersand (&), the pound (#) character and some other punctutation characters as a prefix. For example, the command &W is different than the command W. A few other symbol characters can be found as command prefixes, but these are not standardized.


The EIA/TIA-602 standard says that commands that begin with the plus-sign (+) are reserved for future use, but many modems use commands prefixed with a plus-sign for operations related to the transmission or reception of FAXes.


AT-compatible modems also contain what are called "S" registers. These are called "S" registers simply because access to a given register is specified by the register number preceded by the letter "S". Some AT-compatible modems have over 350 "S" registers that control a wide variety of functions, and these registers are an area of minimal compatibility between different modem brands and modem models. Only the first eleven "S" registers are used consistently throughout the modem industry, despite different vendors selecting different default values for some of these fundamental registers.


In modem documentation and in this reference, when you see a notation like S1, it is referring to "S" register number 1.


Some AT commands also contain optional parameters known as "Modifiers", which are single-letters, numbers or symbols that alter the default behavior of the command to the immediate left of this character on the command line, and may change the modems default behavior for subsequent commands. Commands that accept a numeric modifier assume that the number 0 has been entered if no other number is specified. For example, the commands "B0" and "B" are considered by the modem to be identical.


It should be noted that in the original Hayes Smartmodem 1200, the distinction between dialing modifiers and commands was somewhat blurred, which is why the letters used in dialing modifiers are not used as the letters for commands. Even after a firm line was drawn between commands and Dial command modifiers in subsequent models, the "P" and "T" dialing modifiers continue to be accepted as free-standing commands.


The "T" and "P" Dial modifiers of a dialing command are also examples of modifiers that remain in effect for subsequent dialing operations until the modem is reset or until the previous setting is changed again. Some modifiers can also be saved in non-volatile memory and remain in effect after the modem is reset or power cycled.


In general, multiple AT commands can be submitted to the modem on a single line, although certain commands only make sense if they appear as the last item on a command line. For example, the command to tell the modem to wait for dial-tone before dialing a number must appear before the command to dial the number itself.