nmea0183

所属分类:嵌入式/单片机/硬件编程
开发工具:Rust
文件大小:0KB
下载次数:0
上传日期:2023-08-14 18:51:25
上 传 者sh-1993
说明:  锈蚀NMEA 0183分析器。主要针对嵌入式编程,但不限于。不依赖于std和任何外部依赖项,核心...,
(Rust NMEA 0183 parser. Targeting mostly embedded programming but not limited to. Do not relies on std and any external dependencies, core Rust only.)

文件列表:
.travis.yml (878, 2023-08-14)
Cargo.toml (793, 2023-08-14)
LICENSE (1525, 2023-08-14)
src/ (0, 2023-08-14)
src/common.rs (2215, 2023-08-14)
src/coords.rs (12072, 2023-08-14)
src/datetime.rs (5802, 2023-08-14)
src/gga.rs (5137, 2023-08-14)
src/gll.rs (1538, 2023-08-14)
src/lib.rs (14792, 2023-08-14)
src/modes.rs (4206, 2023-08-14)
src/rmc.rs (2331, 2023-08-14)
src/vtg.rs (1534, 2023-08-14)
tests/ (0, 2023-08-14)
tests/parsing.rs (10108, 2023-08-14)

[![Crates.io](https://img.shields.io/badge/crates.io-v0.3.1-orange.svg?longCache=true)](https://crates.io/crates/nmea0183) [![Build Status](https://travis-ci.org/nsforth/nmea0183.svg?tag=v0.3.1)](https://travis-ci.org/nsforth/nmea0183) [![Codecov coverage status](https://codecov.io/gh/nsforth/nmea0183/branch/master/graph/badge.svg)](https://codecov.io/gh/nsforth/nmea0183) # 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](https://docs.rs/nmea0183/latest/nmea0183/struct.Parser.html) with [new](https://docs.rs/nmea0183/latest/nmea0183/struct.Parser.html#method.new) and than use methods like [parse_from_byte](https://docs.rs/nmea0183/latest/nmea0183/struct.Parser.html#method.parse_from_bytes) or [parse_from_bytes](https://docs.rs/nmea0183/latest/nmea0183/struct.Parser.html#method.parse_from_bytes). If parser accumulates enough data it will return [ParseResult](https://docs.rs/nmea0183/latest/nmea0183/enum.ParseResult.html) 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`: ```rust 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: ```rust 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](https://docs.rs/nmea0183/latest/nmea0183/struct.Parser.html) like so: ```rust 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.

近期下载者

相关文件


收藏者