Giter Club home page Giter Club logo

nmea-parser's Introduction

NMEA Parser for Rust

NMEA Parser on crates.io NMEA Parser on docs.rs

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

Usage

Include the following fragment in your Cargo.toml file:

[dependencies]
nmea-parser = "0.4.1"

The following sample program uses the crate to parse the given NMEA sentence and to print some fields of the resulting data object. The program relies on plain unwrap() functions 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 the parsed data 
for sentence in sentences {    
    match parser.parse_sentence(sentence)? {
        ParsedSentence::VesselDynamicData(vdd) => {
            println!("MMSI:    {}",        vdd.mmsi);
            println!("Speed:   {:.1} kts", vdd.sog_knots.unwrap());
            println!("Heading: {}°",       vdd.heading_true.unwrap());
            println!("");
        },
        ParsedSentence::VesselStaticData(vds) => {
            println!("MMSI:  {}", vds.mmsi);
            println!("Flag:  {}", vds.country().unwrap());
            println!("Name:  {}", vds.name.unwrap());
            println!("Type:  {}", vds.ship_type);
            println!("");
        },
        ParsedSentence::Gga(gga) => {
            println!("Source:    {}",     gga.source);
            println!("Latitude:  {:.3}°", gga.latitude.unwrap());
            println!("Longitude: {:.3}°", gga.longitude.unwrap());
            println!("");
        },
        ParsedSentence::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 program 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, 18-19, 21, 24 and 27
GNSS sentences GGA, RMC, GSA, GSV, VTG, GLL
Satellite systems GPS, GLONASS, Galileo, BeiDou, NavIC and QZSS

Roadmap

Until version 1.0 refactoring and renaming of crate's code elements is likely to happen. The following table shows the plan to include different sentences in the crate. Prioritisation is based on estimated significance and implementation effort of each item.

Version Category Content
0.5 AIS VDM/VDO types 9-17
0.6 GNSS ALM, DTM, GBS, HDT, ROT, STN, TRF, VBW, ZDA, XTC, XTE
0.7 AIS VDM/VDO types 20, 22, 23, 25 and 26
0.8 AIS VDM/VDO types 6-8
1.0 general Stable API, optimizations, enhanced documentation
1.2 GNSS AAM, BOD, BWC, R00, RMB, RTE, WPL, ZTG
1.3 GNSS APB, RMA, GRS, GST, MSK, MSS, STN, VBW

Minimum Rust version

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

License

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

nmea-parser's People

Contributors

zaari avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.