Download Graphics System in Vehicle Electronics

Transcript
received “$”
1. Search for “$”
Rx
2. Retrieve
address field
received “,”
Rx timeout
3. Receive
sentence data
received “*”
NMEA sentence
processed
tim
7. Wait for
ST eou
second ST and
err t o
or r
process NMEA
sentence
Rx timeout or
checksum error
6. Wait for
received
ST (HEX 0D)
HEX 0D
4. Get first
checksum
character
5. Get second
checksum
character
wait for first
EOS character
(a)
$
1. start
2. prefix +
sentence ID
$
supported
unsupported
wait
NMEA sentence
processed
checksum
error
3. data
4. compute
checksum
(b)
Figure 2.13: (a) Variakojis state-machine (b) My simplified state-machine
To track the structure of the NMEA data you can use a state machine.
The state machine might be formed to look for dollar signs, records characters until it sees a comma, decides if the sentence is interesting, if it is
it records characters until the end of the line, then validates the checksum
and parses the fields it wants. If the sentence isn’t one of interest, or if any
errors occur, it goes back to waiting for a dollar sign.
Design proposal for parser The parser can be composed of two main
parts. One function, messageSplit, which manages the breakdown of the
sentence through the use of the comma character ”,” that exist between all
the data fields. It presents the words as strings and keep track of whether
there are more data fields or not.
The second function keeps track of whether there is support for the
requested sentence. It receives the data stream directly from GPS receiver
(as a call parameter) via the serial port and it will also be called with a
”struct” parameter that can be used to store information. It uses the first
function to read one data field at a time. By scanning the first field (e.g.
$GPGGA) the function knows what sentence type the stream transmit and
then (if supported) to overwrite/update all data fields. These will finally be
converted to be readable and easily understood by humans. By using this
method you are forced to make comparisons between your first field and
strings in, for example, case or if statements.
Most of the work done by the parser consists of determining the sentence
type and separating the different items. The parsed data are stored as strings
in a struct. The parser can be extended to recognize if the data coming from
the GPS receiver is valid by using the optional checksum.
2.4.3
Conclusion
The GPS system gives everyone with a GPS receiver the possibility to determine their position. The basis for positioning determination is, to calculate
39