Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added parsing ZFO and ZTG messages#87

Merged
elpiel merged 6 commits into
AeroRust:mainfrom
taavit:zfo-ztg-message
May 14, 2023
Merged

Added parsing ZFO and ZTG messages#87
elpiel merged 6 commits into
AeroRust:mainfrom
taavit:zfo-ztg-message

Conversation

@taavit
Copy link
Copy Markdown

@taavit taavit commented Apr 10, 2023

Comment thread src/sentences/utils.rs Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From what I see, all values can be negative and we should check this case.

Another thing that would be good to do is avoid using i64 and only when creating the Duration to cast the value to i64.

This will give us only 1 place where we should check if we can cast e.g. u32, u64 to i64.

Comment thread src/sentences/utils.rs Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • Please use a different value for the number, e.g. u8 will also be sufficient.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

i64 makes easier following conversion to Duration (as Duration accepts i64).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be better to fail value parsing as early as possible.

And Yes, Duration takes i64, however, we could easily convert it with From: https://doc.rust-lang.org/std/primitive.i64.html#impl-From%3Cu8%3E-for-i64

It's better to parse a mostly correct value, instead of very wrong value. parsing i64 could also take longer and can have bigger impact on constraint device since this first parser can actually succeed event with e.g. negative value.

Even if the architecture is 32 bit, 64 bit numbers are still supported but not by the hardware itself, so are less performant.

Comment thread src/sentences/utils.rs Outdated
Comment on lines 76 to 75
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread src/sentences/utils.rs Outdated
Comment thread src/sentences/zfo.rs Outdated
Comment thread src/sentences/zfo.rs Outdated
Comment thread src/sentences/ztg.rs Outdated
Comment thread src/sentences/ztg.rs Outdated
@elpiel
Copy link
Copy Markdown
Member

elpiel commented Apr 17, 2023

Thank you for your PR! I've left some improvements notes, which should be reviewed and applied to the rest of the sentences as well.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2023

Codecov Report

Patch coverage: 79.54% and project coverage change: +0.04 🎉

Comparison is base (d8f668b) 80.22% compared to head (2fd41b3) 80.26%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #87      +/-   ##
==========================================
+ Coverage   80.22%   80.26%   +0.04%     
==========================================
  Files          31       33       +2     
  Lines        1153     1196      +43     
==========================================
+ Hits          925      960      +35     
- Misses        228      236       +8     
Impacted Files Coverage Δ
src/parser.rs 78.51% <0.00%> (-0.62%) ⬇️
src/sentences/mod.rs 0.00% <ø> (ø)
src/sentences/zfo.rs 83.33% <83.33%> (ø)
src/sentences/ztg.rs 83.33% <83.33%> (ø)
src/parse.rs 73.86% <100.00%> (+1.24%) ⬆️
src/sentences/utils.rs 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@elpiel
Copy link
Copy Markdown
Member

elpiel commented May 14, 2023

Thank you once again for your contributions @taavit !

@elpiel elpiel merged commit 2d30392 into AeroRust:main May 14, 2023
@taavit taavit deleted the zfo-ztg-message branch May 14, 2023 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants