Code Snippets

AT Commands and Serial Port Communication



AT Commands

OVERVIEW

  • AT commands are instructions used to control a modem.
  • AT is the abbreviation of Attention.
  • Also called Hayes command set which is a specific command-language originally developed for the Hayes Smartmodem 300 baud modem.
  • The command set consists of a series of short text strings which combine together to produce complete commands

GSM Modem

  • A GSM modem can be an external modem device. Insert a GSM SIM card into this modem, and connect the modem to an available serial port on your computer.
  • A GSM modem can be a PC Card installed in a notebook computer, such as the Nokia Card Phone.
  • A GSM modem could also be a standard GSM mobile phone with the appropriate cable and software driver to connect to a serial port on your computer.
  • Compatibility Issues
  • A dedicated GSM modem (external or PC Card) is usually preferable to a GSM mobile phone. This is because of some compatibility issues that can exist with mobile phones.
  • For Ex: some mobile phones will not allow you to correctly receive SMS text messages longer than 160 bytes (known as “concatenated SMS” or “long SMS”). This is because these long messages are actually sent as separate SMS messages, and the phone attempts to reassemble the message before forwarding via the modem interface.
  • What does a GSM Modem Do?
  • A GSM modem is a wireless modem that works with a GSM wireless network. A wireless modem behaves like a dial-up modem. The main difference between them is that a dial-up modem sends and receives data through a fixed telephone line while a wireless modem sends and receives data through radio waves.

History of the AT Command Set

  • In the early 1990s, a company called Hayes began manufacturing the Hayes Smart modem
  • Hayes developed and published a command set to control the modem over a serial line. This command set became popular among consumer modem manufacturers, and was cloned a thousand times. Known as both the “Hayes command set” and the “AT command set”

What are AT Commands?

  • AT commands are instructions used to control a modem.

  • Almost all of the Hayes modem commands start with the two letter sequence AT – for getting the modem’s attention. Because of this, modem commands are often called AT Commands.

Command State / On-line State

  • With respect of controlling the modem a Hayes-compatible modem is one of two main states:
  • Command State
  • The modem interprets data from the DTE as modem commands. The modem can be in command state while still keeping a connection with a remote party.
  • On-line State
  • The modem interprets data from the DTE as payload and transmits it to the other party. This state requires that a connection to the remote site has been established.
  • AT commands are accepted by the modem only when in command mode. The modem can be forced into command mode

Serial Port Communication

A serial port is a serial communication physical interface through which information transfers in or out one bit at a time

Virtual serial ports

  • A virtual serial port is an emulation of the standard serial port. This port is created by software which enable extra serial ports in an operating system without additional hardware installation (such as expansion cards, etc.)
  • Virtual serial ports are common with Bluetooth
  • Serial Communication Settings
  • Many settings are required for serial connections
  • Speed – The port speed and device speed must match.
  • Data Bits-The number of data bits in each character can be 5 , 6 (rarely used), 7 (for true ASCII), 8 (for any kind of data, as this matches the size of a byte), or 9 (rarely used). 8 data bits are almost universally used in newer applications.

Serial Communication Settings

  • Parity is a method of detecting some errors in transmission. Where parity is used with a serial port, an extra data bit is sent with each data character, arranged so that the number of 1 bits in each character, including the parity bit, is always odd or always even. If a byte is received with the wrong number of 1 bits, then it must have been corrupted
  • Serial Communication Settings
  • Stop bits sent at the end of every character allow the receiving signal hardware to detect the end of a character and to resynchronise with the character stream. Electronic devices usually use one stop bit. If slow electromechanical teleprinters are used, one-and-one half or two stop bits are required.
  • A serial port may use signals in the interface to pause and resume the transmission of data. For example, a slow printer might need to handshake with the serial port to indicate that data should be paused while the mechanism advances a line.
  • Serial Communication Settings
  • Baud rate – A baud rate, by definition, means the number of times a signal in a communications channel changes state or varies. For example, a 2400 baud rate means that the channel can change states up to 2400 times per second. The term “change state”, means that it can change from 0 to 1 or from 1 to 0 up to X (in this case, 2400) times per second.

AT commands set for Nokia GSM and WCDMA products

Call control

ATA - Answer command

ATD - Dial command ATH Hang up call

ATL - Monitor speaker loudness ATM Monitor speaker mode

ATO - Go on-line ATP Set pulse dial as default

ATT - Set tone dial as default AT+CSTA Select type of address AT+CRC Cellular result codes

Data card control commands

ATI - Identification

ATS - Select an S-register ATZ Recall stored profile

AT&F - Restore factory settings AT&V View active configuration

AT&W - Store parameters in given profile AT&Y Select Set as powerup option

AT+CLCK - Facility lock command AT+COLP Connected line identification presentation

AT+GCAP – Request complete capabilities list

AT+GMI -Request manufacturer identification AT+GMM Request model identification

AT+GMR - Request revision identification

AT+GSN -Request product serial number identification (IMEI)

Phone control commands

AT+CBC - Battery charge

AT+CGMI -Request manufacturer identification

AT+CGMM -Request model identification

AT+CGMR -Request revision identification

AT+CGSN -Request product serial number identification

AT+CMEE - Report mobile equipment error

AT+CPAS - Phone activity status

AT+CPBF - Find phone book entries

AT+CPBR -Read phone book entry

AT+CPBS -Select phone book memory storage

AT+CPBW -Write phone book entry

AT+CSCS -Select TE character set AT+CSQ Signal quality

Computer data card interface commands

ATE - Command Echo

ATQ -Result code suppression

ATV -Define response format

ATX - Response range selection

AT&C -Define DCD usage

AT&D -Define DTR usage

AT&K -Select flow control

AT&Q -Define communications mode option

AT&S -Define DSR option

AT+ICF -DTE-DCE character framing AT+IFC DTE-DCE Local flow control

AT+IPR -Fixed DTE rate

SMS commands

AT+CSMS -Select message service

AT+CPMS -Preferred message storage

AT+CMGF - Message format

AT+CSCA -Service centre address

AT+CSMP - Set text mode parameters

AT+CSDH - Show text mode parameters

AT+CSCB -Select cell broadcast message types

AT+CSAS -Save settings

AT+CRES -Restore settings

AT+CNMI -New message indications to TE AT+CMGL List messages

AT+CMGR -Read message

AT+CMGS -Send message

AT+CMSS - Send message from storage

AT+CMGW -Write message to memory

AT+CMGD -Delete message

SMS PDU Mode

AT+CMGL -List Messages

AT+CMGR -Read message

AT+CMGS - Send message

AT+CMGW -Write message to memory

PDU Format

There are two ways of sending and receiving SMS messages: by text mode and by PDU (protocol description unit) mode.

The text mode is unavailable on most phones

The PDU string contains not only the message, but also a lot of meta-information about the sender, his SMS service center, the time stamp etc. It is all in the form of hexa-decimal octets or decimal semi-octets.

Share

Thanks for reading my blog. If you like what I write, why not subscribe to my feed?

If you are busy, I can send the latest post to your email. Just subscribe to my email updates.

 

Enter your email address:

Delivered by FeedBurner

Discussion

No comments for “AT Commands and Serial Port Communication”

Post a comment