Skip to content

Commit

Permalink
Typos and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nstaroverov committed Aug 20, 2019
1 parent 79e6d3d commit 7a4500e
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "nmea0183"
version = "0.1.0"
authors = ["Nikita Staroverov <[email protected]>"]
edition = "2018"
description = "NMEA 0183 Parser tartgetting mostly embedded devices but not limited to."
description = "NMEA 0183 parser targetting mostly embedded devices but not limited to."
homepage = "https://github.com/nsforth/nmea0183"
license = "BSD-3-Clause"
keywords = ["NMEA", "nmea", "parser", "gps", "embedded"]
Expand Down
71 changes: 69 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,69 @@
# nmea-0183
Rust NMEA 0183 parser. Targeting mostly embedded programming but not limited to. Do not relies on std and any external dependencies. Core Rust only.
% NMEA 0183 Parser.

NMEA 0183 parser. Implemented most used sentences like RMC, VTG, GGA, GLL.
Parser do not use heap memory and relies only on `core`.

You should instantiate `Parser` with `new` and than use methods like `parse_from_byte` or `parse_from_bytes`.
If parser accumulates enough data it will return `ParseResult` on success or `&str` that describing an error.

You do not need to do any preprocessing such as split data to strings or NMEA sentences.

# Examples

If you could read a one byte at a time from the receiver you may use `parse_from_byte`:
```
use nmea0183::{Parser, ParseResult};
let nmea = b"$GPGGA,145659.00,5956.695396,N,03022.454999,E,2,07,0.6,9.0,M,18.0,M,,*62\r\n$GPGGA,,,,,,,,,,,,,,*00\r\n";
let mut parser = Parser::new();
for b in &nmea[..] {
if let Some(result) = parser.parse_from_byte(*b) {
match result {
Ok(ParseResult::GGA(Some(gga))) => { }, // Got GGA sentence
Ok(ParseResult::GGA(None)) => { }, // Got GGA sentence without valid data, receiver ok but has no solution
Ok(_) => {}, // Some other sentences..
Err(e) => { } // Got parse error
}
}
}
```

If you read many bytes from receiver at once or want to parse NMEA log from text file you could use Iterator-style:
```
use nmea0183::{Parser, ParseResult};
let nmea = b"$GPGGA,,,,,,,,,,,,,,*00\r\n$GPRMC,125504.049,A,5542.2389,N,03741.6063,E,0.06,25.82,200906,,,A*56\r\n";
let mut parser = Parser::new();
for result in parser.parse_from_bytes(&nmea[..]) {
match result {
Ok(ParseResult::RMC(Some(rmc))) => { }, // Got RMC sentence
Ok(ParseResult::GGA(None)) => { }, // Got GGA sentence without valid data, receiver ok but has no solution
Ok(_) => {}, // Some other sentences..
Err(e) => { } // Got parse error
}
}
```

# Panics

Should not panic. If so please report issue on project page.

# Errors

`Unsupported sentence type.` - Got currently not supported sentence.

`Checksum error!` - Sentence has wrong checksum, possible data corruption.

`Source is not supported!` - Unknown source, new sattelite system is launched? :)

`NMEA format error!` - Possible data corruption. Parser drops all accumulated data and starts seek new sentences.

It's possible to got other very rare error messages that relates to protocol errors. Receivers nowadays mostly do not violate NMEA specs.

# Planned features

GSA and GSV parsing.

Filtering by sentence type and/or source. Parser will silently drops unneeded sentences/sources.

0 comments on commit 7a4500e

Please sign in to comment.