Skip to content
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

Merged
merged 5 commits into from
Oct 27, 2022
Merged

Conversation

bahelms
Copy link

@bahelms bahelms commented Oct 21, 2022

Add AAM sentence parser

@bahelms
Copy link
Author

bahelms commented Oct 21, 2022

@elpiel I have a question about the AAM sentence. I see that Nmea::parse does not support all sentences. It would seem AAM should also not be supported here based on the docs:

/// 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?

@elpiel
Copy link
Member

elpiel commented Oct 22, 2022

Yes, that is correct.

Thank you for the PR 🎉

@elpiel
Copy link
Member

elpiel commented Oct 24, 2022

@bahelms should I take a look at the PR or do you need to finish something else first?
There is also a conflict right now, would ou mind resolving it?

@bahelms bahelms marked this pull request as ready for review October 24, 2022 18:36
@bahelms
Copy link
Author

bahelms commented Oct 24, 2022

@bahelms should I take a look at the PR or do you need to finish something else first? There is also a conflict right now, would ou mind resolving it?

@elpiel Yes, it's ready for review now. Thanks!

Copy link
Member

@elpiel elpiel left a 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.

Comment on lines 52 to 53
let (i, field2) = anychar(i)?;
let perpendicular_passed = if field2 == 'A' {
Copy link
Member

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

Copy link
Author

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 Show resolved Hide resolved
src/sentences/aam.rs Outdated Show resolved Hide resolved
src/sentences/aam.rs Show resolved Hide resolved
let (i, arrival_circle_radius) = opt(float)(i)?;
let (i, _) = char(',')(i)?;

let (i, radius_units) = opt(anychar)(i)?;
Copy link
Member

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 Show resolved Hide resolved
let perpendicular_passed = match perpendicular_passed {
'A' => Some(true),
'V' => Some(false),
char => unreachable!("{} is not a valid AAM-Perpendicular Passed value", char),
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha.

Copy link
Member

@elpiel elpiel left a 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
Copy link

codecov bot commented Oct 27, 2022

Codecov Report

Base: 78.54% // Head: 79.22% // Increases project coverage by +0.67% 🎉

Coverage data is based on head (08ccbbb) compared to base (d5f1209).
Patch coverage: 96.15% of modified lines in pull request are covered.

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              
Impacted Files Coverage Δ
src/parse.rs 80.39% <ø> (ø)
src/parser.rs 79.36% <0.00%> (+0.08%) ⬆️
src/sentences/mod.rs 0.00% <ø> (ø)
src/sentences/aam.rs 100.00% <100.00%> (ø)

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@elpiel elpiel merged commit b73418a into AeroRust:main Oct 27, 2022
@elpiel elpiel linked an issue Oct 27, 2022 that may be closed by this pull request
@bahelms
Copy link
Author

bahelms commented Oct 27, 2022

LGTM. A BIG Thanks 🎉 for contributing to the project!

PS: Let's see if CI runs successfully and we can merge it.

Thank you! My pleasure.

@bahelms bahelms deleted the aam-sentence-parsing branch October 27, 2022 15:42
@elpiel elpiel added the hacktoberfest-accpeted Hacktoberfest accepted PR label Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accpeted Hacktoberfest accepted PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supporting additional sentences
2 participants