Compare commits

...

3 Commits
0.2.0 ... main

Author SHA1 Message Date
Thomas Klaehn
5eda664a47 Fix: Handle options of nmea messages 2025-01-16 13:55:19 +01:00
tkl
299c4f5a5f Version bump 2025-01-15 10:55:59 +00:00
Thomas Klaehn
96da5c9e74 Version bump
Signed-off-by: Thomas Klaehn <thomas.klaehn@perinet.io>
2025-01-15 11:44:00 +01:00
3 changed files with 22 additions and 10 deletions

2
Cargo.lock generated
View File

@ -102,7 +102,7 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
[[package]] [[package]]
name = "gps_parser" name = "gps_parser"
version = "0.1.0" version = "0.3.1"
dependencies = [ dependencies = [
"chrono", "chrono",
"nmea-parser", "nmea-parser",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "gps_parser" name = "gps_parser"
version = "0.1.0" version = "0.3.1"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -6,10 +6,10 @@ use nmea_parser::*;
#[derive(Debug)] #[derive(Debug)]
pub struct ParseResult { pub struct ParseResult {
lat: f64, pub lat: f64,
lon: f64, pub lon: f64,
timestamp: DateTime<Utc>, pub timestamp: DateTime<Utc>,
speed: f64 pub speed: f64,
} }
pub struct GpsParser { pub struct GpsParser {
@ -50,13 +50,25 @@ impl GpsParser {
match parser.parse_sentence(&line)? { match parser.parse_sentence(&line)? {
ParsedMessage::Gga(gga) => { ParsedMessage::Gga(gga) => {
parsed_gga = true; parsed_gga = true;
res.lat = gga.latitude.unwrap(); res.lat = match gga.latitude {
res.lon = gga.longitude.unwrap(); Some(value) => value,
res.timestamp = gga.timestamp.unwrap(); _none => 0.0,
};
res.lon = match gga.longitude {
Some(value) => value,
_none => 0.0,
};
res.timestamp = match gga.timestamp {
Some(value) => value,
_none => Utc::now(),
};
}, },
ParsedMessage::Vtg(vtg) => { ParsedMessage::Vtg(vtg) => {
parsed_vtg = true; parsed_vtg = true;
res.speed = vtg.sog_kph.unwrap(); res.speed = match vtg.sog_kph {
Some(value) => value,
_none => 0.0,
};
}, },
_ => { _ => {
} }