#gps #parser #nmea #0183 #nmea0183

titanic

Unsinkable parser for the GGA sentence of the NMEA 0183 protocol (parses GPS positions)

1 unstable release

0.1.0 Sep 6, 2018

#8 in #gps

Download history 69/week @ 2018-09-12 3/week @ 2018-09-19 1/week @ 2018-09-26 2/week @ 2018-10-03 3/week @ 2018-10-10 17/week @ 2018-10-17

5 downloads per month

MIT license

78KB
2K SLoC

Nmea 0183 GGA Parser

This is a parser for the GGA sentence of the NMEA 0183 protocol.

More sentences may be added in the future, but are not planned at the moment. Accepts data as described here.

Setup

Add this to Cargo.toml:

[dependencies]
titanic = "0.1.0"

Then put this in your crate root:

extern crate titanic;

Usage

GgaParser can be used like an Iterator. Calling next on GgaParser blocks until

  • it finds '$',
  • reaches EOF
  • an I/O error occurs.

'$' signals the beginning of a new sentence. If the new sentence is of the type GGA, it will be parsed if possible. The parser iterates over Result<GgaSentence, ParseError>.

EOF signals the end of the iterator.

# extern crate titanic;
# use std::io::Cursor;
use titanic::GgaParser;

let data = Cursor::new("$GPGGA,142212.000,1956.9418,S,06938.0163,W,1,3,5.74,102.1,M,47.9,M,,*57");
let parser = GgaParser::new(data).unwrap();

for gga in parser {
    let gga = gga.unwrap();
    println!(
       "Time: {}, we are here: {}°, {}°",
       gga.utc.format("%H:%M:%S"),
       gga.lat.unwrap(),
       gga.long.unwrap()
   );
}
// Prints "Time: 14:22:12, we are here: -19.94903°, -69.633605°"

Dependencies

~1MB
~12K SLoC