titanic

Crates.iotitanic
lib.rstitanic
version0.1.0
sourcesrc
created_at2018-09-06 13:09:17.497696
updated_at2018-09-06 13:09:17.497696
descriptionUnsinkable parser for the GGA sentence of the NMEA 0183 protocol (parses GPS positions).
homepage
repositoryhttps://github.com/49nord/titanic-rs
max_upload_size
id83165
size79,615
owners (github:49nord:owners)

documentation

README

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°"
Commit count: 76

cargo fmt