05.03.2013 Views

Data Hacking

Data Hacking

Data Hacking

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

196 Part III — <strong>Data</strong> <strong>Hacking</strong><br />

NMEA Sentences<br />

The concept behind NMEA is to send data one line at a time. Each line of data (called a sentence)<br />

is completely standalone — self-contained and independent from other sentences. There are two<br />

kinds of sentences:<br />

Standard sentences for each device category<br />

Proprietary sentences for use by the individual devices and manufacturers<br />

All of the standard sentences have a two-letter prefix defining the device that uses that sentence<br />

type. For GPS receivers, the prefix is always GP — most sentences that a GPS receiver<br />

understands are prefixed by these two letters. They are followed by a three-letter sequence that<br />

defines what the sentence contains.<br />

As I’ve already mentioned, the NMEA standard permits hardware manufacturers to define and<br />

use their own proprietary sentences for any purpose they see fit. The only prerequisite is that all<br />

proprietary sentences must begin with the letter P, and are followed with three letters that<br />

identify the manufacturer controlling that sentence. For example, Garmin sentences start with<br />

“PGRM,” while Magellan sentences begin with “PMGN.”<br />

Proprietary sentences vary from receiver to receiver and over time and are not covered here.<br />

Proprietary sentences contain more, and more specific, information than NMEA does, which is<br />

considered the lowest common denominator.<br />

NMEA Sentence Structure<br />

Each NMEA sentence begins with a dollar sign ($) and ends with a carriage return/line feed<br />

sequence. Most sentences can be no longer than 80 characters. All the data is contained inside<br />

this single line, and data items are separated by commas. The data itself is in the form of<br />

ASCII text, and the data can, especially if it’s complex, be spread over many separate NMEA<br />

sentences, but it is normally fully contained in just one sentence.<br />

The precision of different sentences varies depending on the data. For example, time information<br />

might be given in seconds correct to one decimal place, while positional information might be<br />

given to three or even four digits after the decimal place. NMEA uses commas to separate individual<br />

fields of data. If the field doesn’t contain data, it’s left blank, but a comma is still required.<br />

To improve accuracy, there is a provision to include a checksum at the end of each sentence,<br />

which may or may not be checked by the unit that reads the data. The checksum field consists<br />

of an * and two hex digits representing the exclusive OR of all characters between, but not<br />

including, the $ and *. The checksum is used to validate the contents of the sentence.<br />

A checksum is required on some sentences, and optional on others.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!