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.
Include the following fragment in your Cargo.toml
file:
toml
[dependencies]
nmea-parser = "0.5.0"
The following sample program uses the crate to parse the given NMEA sentences and to print some
parsed fields. The program relies on unwrap()
function to simplify the example. In real-life
applications proper handling of None
cases is needed.
```rust use nmea_parser::*;
// Create parser and define sample sentences let mut parser = NmeaParser::new(); let sentences = vec![ "!AIVDM,1,1,,A,H42O55i18tMET00000000000000,26D", "!AIVDM,1,1,,A,H42O55lti4hhhilD3nink000?050,040", "$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.parsesentence(sentence)? {
ParsedMessage::VesselDynamicData(vdd) => {
println!("MMSI: {}", vdd.mmsi);
println!("Speed: {:.1} kts", vdd.sogknots.unwrap());
println!("Heading: {}°", vdd.headingtrue.unwrap());
println!("");
},
ParsedMessage::VesselStaticData(vsd) => {
println!("MMSI: {}", vsd.mmsi);
println!("Flag: {}", vsd.country().unwrap());
println!("Name: {}", vsd.name.unwrap());
println!("Type: {}", vsd.shiptype);
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 program outputs the following lines:
``` MMSI: 271041815 Flag: TR Name: PROGUY Type: passenger
Source: Galileo Latitude: 48.117° Longitude: 11.517° ```
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-19, 21, 24 and 27 | |GNSS sentences |GGA, RMC, GSA, GSV, VTG, GLL | |Satellite systems|GPS, GLONASS, Galileo, BeiDou, NavIC and QZSS |
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.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, documentation enhancements, even more test cases| |1.1 |GNSS |AAM, BOD, BWC, R00, RMB, RTE, WPL, ZTG | |1.2 |GNSS |APB, RMA, GRS, GST, MSK, MSS, STN, VBW |
The crate's minimum supported Rust toolchain version is 1.44.
This crate is licensed under [Apache 2.0 license] which also includes the liability and warranty statements.