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

no_std #41

Merged
merged 14 commits into from
Aug 10, 2022
Merged

no_std #41

merged 14 commits into from
Aug 10, 2022

Conversation

patrickoppel
Copy link

Try at an implementation replacing std::Vec with heapless::Vec as mentioned in #10

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.

@Dushistov @hargoniX would any of you be able to take a look at this PR too?

src/sentences/gsa.rs Outdated Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
src/sentences/gsa.rs Outdated Show resolved Hide resolved
src/sentences/gsa.rs Outdated Show resolved Hide resolved
src/sentences/gsv.rs Show resolved Hide resolved
src/sentences/gsv.rs Outdated Show resolved Hide resolved
This was linked to issues Jul 16, 2022
@elpiel
Copy link
Member

elpiel commented Jul 16, 2022

Some of the changes actually broke the parse, I took the code and fixed almost all the issues.
only the test_gsv_real_data tests fails right now

@elpiel
Copy link
Member

elpiel commented Jul 16, 2022

I made a few improvements on the functional_tests .
the failing test has the same GPS satellites twice and I'm not sure which data should be in the expected parsed data.

elpiel and others added 3 commits July 16, 2022 16:09
@patrickoppel
Copy link
Author

patrickoppel commented Jul 17, 2022

Having the same satellite in the satellites_scan twice should be an error, currently the implementation in satellites() returns the first mention of it in the GSV data. In the real world this should never happen with NMEA data.
So I think there's two possibilities:

  • leave satellites() as is and change the test to reflect the first mention (this)
  • implement a check and error in merge_gsv_data() and write another test to test for the error

@elpiel
Copy link
Member

elpiel commented Jul 17, 2022

Ok, I found the problem @patrickoppel. You forgot to rev() when you were refactoring the code.
The NMEA sentences can contain multiple satellites twice, this is because such a log can contain multiple received messages.

- revert functional_tests data
@patrickoppel
Copy link
Author

If it can contain multiple satellites twice the total number of satellites in view can be a lot higher than what we set now

@elpiel
Copy link
Member

elpiel commented Jul 17, 2022

This should actually be ready now:
patrickoppel#3

Fixed the test data and the missing rev(), removed alloc, some docs fixes and we're now officially no_std 🎉 (I've added the category to Cargo.toml as well)

@elpiel elpiel changed the title No_std no_std Jul 17, 2022
No std test fix & last `no_std` preparations
@codecov
Copy link

codecov bot commented Jul 17, 2022

Codecov Report

Merging #41 (b3b4370) into master (80b8057) will increase coverage by 1.08%.
The diff coverage is 88.60%.

@@            Coverage Diff             @@
##           master      #41      +/-   ##
==========================================
+ Coverage   87.12%   88.21%   +1.08%     
==========================================
  Files          15       15              
  Lines        1212     1222      +10     
==========================================
+ Hits         1056     1078      +22     
+ Misses        156      144      -12     
Impacted Files Coverage Δ
src/lib.rs 81.90% <53.33%> (+3.55%) ⬆️
src/sentences/gsa.rs 91.13% <91.30%> (-0.80%) ⬇️
src/sentences/bwc.rs 96.49% <100.00%> (ø)
src/sentences/gsv.rs 95.34% <100.00%> (+0.05%) ⬆️
tests/file_log_parser/mod.rs 90.00% <100.00%> (ø)
tests/functional_tests.rs 98.94% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80b8057...b3b4370. Read the comment docs.

@@ -72,7 +72,7 @@ pub struct Nmea {
pub pdop: Option<f32>,
/// Geoid separation in meters
pub geoid_separation: Option<f32>,
pub fix_satellites_prns: Option<Vec<u32>>,
pub fix_satellites_prns: Option<Vec<u32, 12>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose it should be 58, but it can wait until we can teach this crate to merge GSA messages.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, Can you also provide some info on this merging?

pub fn satellites(&self) -> Vec<Satellite> {
let mut ret = Vec::with_capacity(20);
/// Returns used satellites
pub fn satellites(&self) -> Vec<Satellite, 58> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice if 58 become constant with comment why exactly 58.
And it would be nice to replace 15 with constant time expression that calculate it from 58 in SatsPack.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know what the limits are for these 2 values tbh and I feel more comfortable gradually improving them.
I feel that the code might get more complex especially with the public API and those constant values.

I think we can improve the API a lot and see how we can do the merging of the messages you mentioed.

let sat_key = |sat: &Satellite| (sat.gnss_type() as u8, sat.prn());
for sns in &self.satellites_scan {
for sat_pack in sns.data.iter().rev() {
for sat in sat_pack.iter().flatten() {
// for sat_pack in sns.data.iter().rev() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not remove dead code?

O: core::fmt::Debug,
{
move |mut i: I| {
// let mut acc = crate::lib::std::vec::Vec::with_capacity(4);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dead code?

Copy link
Member

Choose a reason for hiding this comment

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

Dead but this is the original nom code. I think it would be good to leave it as it is.

@Dushistov
Copy link
Collaborator

If it can contain multiple satellites twice the total number of satellites in view can be a lot higher than what we set now

I wonder to see logs of GPS receiver that can work with L1 and L2(C) at the same time.
Would they give the same PRN in one GSA message?

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.

I wonder to see logs of GPS receiver that can work with L1 and L2(C) at the same time.
Would they give the same PRN in one GSA message?

I don't know actually. Maybe if a problem arises we can fix it in the library or if we can find this information somewhere?

O: core::fmt::Debug,
{
move |mut i: I| {
// let mut acc = crate::lib::std::vec::Vec::with_capacity(4);
Copy link
Member

Choose a reason for hiding this comment

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

Dead but this is the original nom code. I think it would be good to leave it as it is.

@@ -72,7 +72,7 @@ pub struct Nmea {
pub pdop: Option<f32>,
/// Geoid separation in meters
pub geoid_separation: Option<f32>,
pub fix_satellites_prns: Option<Vec<u32>>,
pub fix_satellites_prns: Option<Vec<u32, 12>>,
Copy link
Member

Choose a reason for hiding this comment

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

Ok, Can you also provide some info on this merging?

pub fn satellites(&self) -> Vec<Satellite> {
let mut ret = Vec::with_capacity(20);
/// Returns used satellites
pub fn satellites(&self) -> Vec<Satellite, 58> {
Copy link
Member

Choose a reason for hiding this comment

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

I don't know what the limits are for these 2 values tbh and I feel more comfortable gradually improving them.
I feel that the code might get more complex especially with the public API and those constant values.

I think we can improve the API a lot and see how we can do the merging of the messages you mentioed.

@patrickoppel
Copy link
Author

I wouldn't expect them to. If I remember it right, dual band allows the receiver to increase the accuracy of the satellites' positions. So it would still use the same number of satellites and return them in the GSA

@elpiel
Copy link
Member

elpiel commented Aug 10, 2022

I think this is good enough for now. If any problem arise we will fix them in subsequent PR.

@elpiel elpiel merged commit 8a90195 into AeroRust:main Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Try to avoid alloc no_std
3 participants