-
Notifications
You must be signed in to change notification settings - Fork 15
PGN testing #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PGN testing #411
Changes from all commits
cbe32fa
f6c356c
a758b5c
4a28ad8
1287140
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,8 @@ mod tests { | |
| messages::{ | ||
| message::Message, | ||
| pgns::{ | ||
| GnssPositionData, GnssSatsInView, TemperatureExtendedRange, WaterDepth, | ||
| MESSAGE_DATA_OFFSET, | ||
| GnssPositionData, NmeaMessage, NmeaMessageBody, TemperatureExtendedRange, | ||
| WaterDepth, MESSAGE_DATA_OFFSET, | ||
| }, | ||
| }, | ||
| parse_helpers::{ | ||
|
|
@@ -157,10 +157,17 @@ mod tests { | |
| let res = general_purpose::STANDARD.decode_vec(msg_str, &mut data); | ||
| assert!(res.is_ok()); | ||
|
|
||
| let cursor = DataCursor::new(data[MESSAGE_DATA_OFFSET..].to_vec()); | ||
| let message = GnssSatsInView::from_cursor(cursor); | ||
| assert!(message.is_ok()); | ||
| let nmea_message = NmeaMessage::try_from(data); | ||
| assert!(nmea_message.is_ok()); | ||
|
|
||
| let nmea_message = nmea_message.unwrap(); | ||
| let message = match nmea_message.data { | ||
| NmeaMessageBody::GnssSatsInView(val) => Some(val), | ||
| _ => None, | ||
| }; | ||
| assert!(message.is_some()); | ||
| let message = message.unwrap(); | ||
|
|
||
|
Comment on lines
+160
to
+170
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gvaradarajan - New since last review, this now ensures that the NmeaMessage enum gets tested at least once.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you for adding this |
||
| println!("message: {:?}", message); | ||
|
|
||
| let source_id = message.source_id(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,7 +126,7 @@ pub struct GnssSatsInView { | |
| } | ||
|
|
||
| macro_rules! define_pgns { | ||
| ( $(($pgndef:ident, $pgn:expr)),* ) => { | ||
| ( $($pgndef:ident),* ) => { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't push more for this change in #408 because I wasn't completely sure there wasn't a reason it didn't work, but it sure seems to.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh, ok. Sounds good to me
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the one thing to check is whether this |
||
| #[derive(Clone, Debug)] | ||
| pub enum NmeaMessageBody { | ||
| $($pgndef($pgndef)),*, | ||
|
|
@@ -143,7 +143,7 @@ macro_rules! define_pgns { | |
|
|
||
| pub fn from_bytes(pgn: u32, bytes: Vec<u8>) -> Result<Self, crate::parse_helpers::errors::NmeaParseError> { | ||
| Ok(match pgn { | ||
| $($pgn => { | ||
| $($pgndef::PGN => { | ||
| let cursor = DataCursor::new(bytes); | ||
| Self::$pgndef($pgndef::from_cursor(cursor)?) | ||
| }),*, | ||
|
|
@@ -163,15 +163,11 @@ macro_rules! define_pgns { | |
|
|
||
| pub const MESSAGE_DATA_OFFSET: usize = 32; | ||
|
|
||
| define_pgns!( | ||
| (WaterDepth, 128267), | ||
| (TemperatureExtendedRange, 130316), | ||
| (GnssSatsInView, 129540) | ||
| ); | ||
| define_pgns!(WaterDepth, TemperatureExtendedRange, GnssSatsInView); | ||
|
|
||
| pub struct NmeaMessage { | ||
| metadata: NmeaMessageMetadata, | ||
| data: NmeaMessageBody, | ||
| pub metadata: NmeaMessageMetadata, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed for testing, let me know if you would prefer accessors, but I find them less interesting in a language where immutability is the default.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it's just for testing, would
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yes, I think it would. I always forget that that is an option. Too accustomed to C++ having only public/private. If it works I'll make that change before push. |
||
| pub data: NmeaMessageBody, | ||
| } | ||
|
|
||
| impl TryFrom<Vec<u8>> for NmeaMessage { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -504,6 +504,7 @@ impl LocalRobot { | |
| } | ||
|
|
||
| pub fn get_periodic_app_client_tasks(&mut self) -> Vec<Box<dyn PeriodicAppClientTask>> { | ||
| #[allow(unused_mut)] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yes, finally |
||
| let mut tasks = Vec::<Box<dyn PeriodicAppClientTask>>::new(); | ||
|
|
||
| #[cfg(feature = "data")] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is
--no-fail-fast?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It prevents a failing test from stopping the execution of other tests. I'd much prefer to learn in one go all the tests I broke, rather than it stopping on the first failure.