I am using parse_from_bytes and get a silent failure. My debugger cannot follow the code.
I had to switch to using the one byte at a time method.
Test Case:
fn test_parse_nmea_buffer() {
let nmea_data = b"$GNVTG,,T,,M,0.055,N,0.101,K,A*3D\r\n";
let parsed_data = parse_nmea_buffer(nmea_data); // <= fails here
assert_eq!(parsed_data.len(), 1, "Should parse 1 message: got {}", parsed_data.len());
}
Here is the function. I plan to returned the parsed data, but i never get there
pub fn parse_nmea_buffer(buffer: &[u8]) -> Vec<SensorData> {
let mut data: Vec<SensorData> = Vec::new();
let mut parser = Parser::new();
let msgs = parser.parse_from_bytes(buffer);
for msg in msgs {. <= Fails Here!
let msg = match msg {
Ok(msg) => msg,
Err(_) => continue, // ignore parse errors, might be partial message
};
match msg {
ParseResult::GGA(Some(gga)) => parse_gga(&mut data, gga),
ParseResult::GSA(Some(gsa)) => parse_gsa(&mut data, gsa),
ParseResult::GSV(Some(gsv)) => parse_gsv(&mut data, gsv),
ParseResult::GLL(Some(gll)) => parse_gll(&mut data, gll),
ParseResult::RMC(Some(rmc)) => parse_rmc(&mut data, rmc),
ParseResult::VTG(Some(vtg)) => parse_vtg(&mut data, vtg),
ParseResult::ZDA(Some(zda)) => parse_zda(&mut data, zda),
// ignore other messages
_ => {}
}
}
data
}
This should easily be reproducible if you get rid of my more detailed parsing.
I am using parse_from_bytes and get a silent failure. My debugger cannot follow the code.
I had to switch to using the one byte at a time method.
Test Case:
Here is the function. I plan to returned the parsed data, but i never get there
This should easily be reproducible if you get rid of my more detailed parsing.