1 unstable release
Uses old Rust 2015
0.1.0 | Sep 6, 2018 |
---|
#12 in #nmea
79KB
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
~1.5MB
~20K SLoC