-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add AAM sentence parser #62
Conversation
@elpiel I have a question about the AAM sentence. I see that /// Parse any NMEA sentence and stores the result of sentences that include:
/// - altitude
/// - latitude and longitude
/// - speed_over_ground
/// - and other
///
/// The type of sentence is returned if implemented and valid.
pub fn parse(&mut self, sentence: &'a str) -> Result<SentenceType, Error<'a>> { Is this correct? |
Yes, that is correct. Thank you for the PR 🎉 |
@bahelms should I take a look at the PR or do you need to finish something else first? |
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.
Very good PR and a great addition to the crate, thank you!
I have a few small requests and necessary changes to make it correct in that it won't allow bad input.
src/sentences/aam.rs
Outdated
let (i, field2) = anychar(i)?; | ||
let perpendicular_passed = if field2 == 'A' { |
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.
We would like to check for both A & V, because anything else should be an error (e.g. if someone passes G
)
You can check this example:
https://github.com/AeroRust/nmea/blob/main/src/sentences/gll.rs#L71-L76
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.
Added an unreachable
for values other than A or V.
src/sentences/aam.rs
Outdated
let (i, arrival_circle_radius) = opt(float)(i)?; | ||
let (i, _) = char(',')(i)?; | ||
|
||
let (i, radius_units) = opt(anychar)(i)?; |
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.
I have to research what are the possible values but it seems that there is only 1 possible value N
so we should go with that.
src/sentences/aam.rs
Outdated
let perpendicular_passed = match perpendicular_passed { | ||
'A' => Some(true), | ||
'V' => Some(false), | ||
char => unreachable!("{} is not a valid AAM-Perpendicular Passed value", char), |
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.
only when using one_of
this will be unreachable.
Right now, because of anychar
it will match other values like G
and will reach the unreachable!
call.
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.
Gotcha.
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.
LGTM. A BIG Thanks 🎉 for contributing to the project!
PS: Let's see if CI runs successfully and we can merge it.
Codecov ReportBase: 78.54% // Head: 79.22% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #62 +/- ##
==========================================
+ Coverage 78.54% 79.22% +0.67%
==========================================
Files 21 22 +1
Lines 797 823 +26
==========================================
+ Hits 626 652 +26
Misses 171 171
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Thank you! My pleasure. |
Add AAM sentence parser