#nmea #gnss #gps #ais #no-std

no-std nmea-parser

NMEA 0183 parser for AIS and GNSS sentences

15 releases (9 breaking)

0.10.0 Oct 13, 2022
0.9.0 Jan 6, 2022
0.8.0 May 26, 2021
0.7.0 Dec 23, 2020
0.6.0 Nov 18, 2020

#48 in Geospatial

Download history 2989/week @ 2023-12-12 1880/week @ 2023-12-19 435/week @ 2023-12-26 2016/week @ 2024-01-02 2554/week @ 2024-01-09 2495/week @ 2024-01-16 2751/week @ 2024-01-23 2377/week @ 2024-01-30 1372/week @ 2024-02-06 858/week @ 2024-02-13 1471/week @ 2024-02-20 1121/week @ 2024-02-27 1421/week @ 2024-03-05 583/week @ 2024-03-12 503/week @ 2024-03-19 494/week @ 2024-03-26

3,291 downloads per month

Apache-2.0

330KB
6.5K SLoC

NMEA Parser for Rust

NMEA Parser on crates.io NMEA Parser on docs.rs GitHub last commit

This Rust crate aims to cover all AIS sentences and the most important GNSS sentences used with NMEA 0183 standard. It supports both AIS class A and class B.

Usage

Include the following fragment in your Cargo.toml file:

[dependencies]
nmea-parser = "0.10.0"

The following example code fragment uses the crate to parse the given NMEA sentences and to print some parsed fields. It relies on unwrap() function to simplify the example. In real-life applications proper handling of None cases is needed.

use nmea_parser::*;

// Create parser and define sample sentences
let mut parser = NmeaParser::new();
let sentences = vec![
  "!AIVDM,1,1,,A,H42O55i18tMET00000000000000,2*6D",
  "!AIVDM,1,1,,A,H42O55lti4hhhilD3nink000?050,0*40",
  "$GAGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*56",
];

// Parse the sentences and print some fields of the messages
for sentence in sentences {    
    match parser.parse_sentence(sentence)? {
        ParsedMessage::VesselDynamicData(vdd) => {
            println!("MMSI:    {}",        vdd.mmsi);
            println!("Speed:   {:.1} kts", vdd.sog_knots.unwrap());
            println!("Heading: {}°",       vdd.heading_true.unwrap());
            println!("");
        },
        ParsedMessage::VesselStaticData(vsd) => {
            println!("MMSI:  {}", vsd.mmsi);
            println!("Flag:  {}", vsd.country().unwrap());
            println!("Name:  {}", vsd.name.unwrap());
            println!("Type:  {}", vsd.ship_type);
            println!("");
        },
        ParsedMessage::Gga(gga) => {
            println!("Source:    {}",     gga.source);
            println!("Latitude:  {:.3}°", gga.latitude.unwrap());
            println!("Longitude: {:.3}°", gga.longitude.unwrap());
            println!("");
        },
        ParsedMessage::Rmc(rmc) => {
            println!("Source:  {}",        rmc.source);
            println!("Speed:   {:.1} kts", rmc.sog_knots.unwrap());
            println!("Bearing: {}°",       rmc.bearing.unwrap());
            println!("Time:    {}",        rmc.timestamp.unwrap());
            println!("");
        },
        _ => {
        }
    }
}

The example outputs the following lines:

MMSI:  271041815
Flag:  TR
Name:  PROGUY
Type:  passenger

Source:    Galileo
Latitude:  48.117°
Longitude: 11.517°

Features

The following features are included in the published version of the crate. Details about version history can be found from the changelog.

Feature Description
AIS sentences VDM/VDO types 1-5, 9-27
GNSS sentences ALM, DBS, DPT, DTM, GGA, GLL, GNS, GSA, GSV, HDT, MTW, MWV, RMC, VTG, MSS, STN, VBW, VHW, ZDA
Satellite systems GPS, GLONASS, Galileo, BeiDou, NavIC and QZSS

Roadmap

The following table outlines the high-level changes that are going to be included in the future versions. Prioritization is based on estimated significance and implementation effort of each item. Until version 1.0 refactoring and renaming of code elements is likely to happen.

Version Category Content
0.11 AIS VDM/VDO types 6-8
1.0 general Stable API, optimizations, documentation enhancements, even more unit tests, examples
1.1 GNSS AAM, BOD, BWC, HDT, R00, RMB, ROT, RTE, WPL, ZTG, APB, GBS, RMA, GRS, GST, MSK, STN, VBW, XTE, XTR

Minimum Rust version

The crate's minimum supported Rust toolchain version is 1.56.

License

This crate is licensed under Apache 2.0 license which also includes the liability and warranty statements.

Dependencies

~3MB
~58K SLoC