Serial Port Complete - Latest Microcontroller projects

(lily) #1
Formats and Protocols

cally “+++” sent with specific timing requirements to minimize the chance of
switching in error if transmitted data happens to contain the sequence. The
modem responds with “OK”. Switching from command mode to data mode is
automatic after some commands, or a computer can send the “ATO” command
to request a switch.


 

   
Many global positioning system (GPS) devices have either an RS-232 port or a
USB port that functions as a virtual COM port. These devices typically com-
municate with PCs using protocols defined in the NMEA 0183 Interface Stan-
dard available from http://www.nmea.org.
The standard specifies parameters for serial communications and a format for
transmitted data. The communication parameters are typically 4800 bps,
8-N-1. (A high-speed addendum to the standard supports communications at
38,400 bps, and some devices support additional bit rates. Devices with USB
virtual COM ports don’t use the serial parameters.)
The data is plain text, 8 bits per character. The devices transmit the data in
blocks called sentences. Standard sentences use this format:

In addition, vendors can define proprietary sentences, which begin with “$P”
followed by a 3-letter manufacturer ID, vendor-specific data, and CR and LF
codes to end the command. For GPS example code, see Richard Grier’s Hard &
Software (www.hardandsoftware.com).

  


Most computers have other things to do besides waiting to receive data on a
serial port. A data-acquisition system might collect and store data to send at



! 
1 Initial character. Always “$”.
2 Talker ID. Identifies the device type.
3 Sentence ID. Identifies the type of information being sent.
variable Data, comma delimited.
3 “*” character followed by a 2-byte checksum. Optional for
some sentences.
2 End-of-sentence indicator. Always CR LF.
Free download pdf