All Projects → nsforth → nmea0183

nsforth / nmea0183

Licence: BSD-3-Clause license
Rust NMEA 0183 parser. Targeting mostly embedded programming but not limited to. Do not relies on std and any external dependencies, core Rust only.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to nmea0183

nmea msgs
nmea_msgs is a ROS package containing messages related to the NMEA standard
Stars: ✭ 21 (-19.23%)
Mutual labels:  nmea
rpi boat utils
Utilities for Raspberry Pi, mostly for usage on a boat. Includes UART control scripts, traffic measurement tools for Mikrotik (RouterOS) and OpenWrt, AIS wireless daemon, AIS decoder and an extensible boat & IoT sensor daemon for Signal K.
Stars: ✭ 71 (+173.08%)
Mutual labels:  nmea
nmea
NMEA 0183 parser
Stars: ✭ 13 (-50%)
Mutual labels:  nmea
NMEAParser
A library for parsing NMEA messages in C# classes.
Stars: ✭ 14 (-46.15%)
Mutual labels:  nmea
opendlv
OpenDLV - A modern microservice-based software ecosystem powered by libcluon to make vehicles autonomous.
Stars: ✭ 67 (+157.69%)
Mutual labels:  nmea
node-nmea
Parser for NMEA sentences.
Stars: ✭ 23 (-11.54%)
Mutual labels:  nmea
frakegps
Simulate a simple GPS device with gpsd or geoclue2
Stars: ✭ 22 (-15.38%)
Mutual labels:  nmea

Crates.io Build Status Codecov coverage status

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
    }
}

It is possible to ignore some sentences or sources. You can set filter on Parser like so:

use nmea0183::{Parser, ParseResult, Sentence, Source};

let parser_only_gps_gallileo = Parser::new()
    .source_filter(Source::GPS | Source::Gallileo);
let parser_only_rmc_gga_gps = Parser::new()
    .source_only(Source::GPS)
    .sentence_filter(Sentence::RMC | Sentence::GGA);

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].