Skip to content

Conversation

adrian-kong
Copy link
Contributor

@adrian-kong adrian-kong commented Jan 10, 2023

TLDR: previously iterated over existing settings which did not handle case where we attempted to set configs that werent set causing it to not disable ntrip / ethernet before setting.


This was tested by running

cargo run --bin swift-settings --tcp ... --import config.ini

modifying ntrip in config.ini file,

previously would result in

writing ntrip debug False
Error: setting is not modifiable

caused by iterating over the current settings
(since original did not have debug, it would assume the group was not changed)


the new changes iterate over the modified keys (and checking over the changes instead)

the added logging statements show which settings were toggled and can see now ntrip gets disabled prior to settings.

  • (NOTE* this was left unchanged) using --write in swift-settings command will need to manually specify this procedure

@adrian-kong adrian-kong changed the title Adrian/debug settings [CPP-782] settings write order bug fix [CPP-782] Jan 12, 2023
@adrian-kong adrian-kong requested review from a team and silverjam January 12, 2023 02:46
@swiftnav-travis
Copy link

Frontend and Release Workflow Started here

self.write_setting(group, name, value)?;
if !in_config {
Ok(Some(original))
Ok(original) // revert to original if not in new config
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this handle the case where there is no original and it's not in the group, does it set the values to the default?

Copy link
Contributor Author

@adrian-kong adrian-kong Jan 12, 2023

Choose a reason for hiding this comment

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

when theres no original, it wont revert back to original i.e. it gets set
since we can't fetch the field.

this was because ntrip.enable wasn't found - which would turn ntrip to false by default

(this also assumes if its not found, it was false and same with ethernet, if not found its in config mode)
^ not sure if that is true or not however.

EDIT: also added some extra comments,
think it might be best to add tests (but i feel like might be kinda funky 🤔)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also this method no longer needs to return a result (if we allow this case ^^ - which im not sure if ntrip should be false by default if not found, or ethernet in config by default)

@silverjam silverjam requested a review from a team January 12, 2023 04:53
@silverjam
Copy link
Contributor

@adrian-kong Can you add a note to the PR about how this was tested?

@adrian-kong
Copy link
Contributor Author

@adrian-kong Can you add a note to the PR about how this was tested?

added 👍

Some(v) => v,
None => return Ok(true), // update since current values are empty
};
for (name, new_value) in new_group.iter() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was basically the one of the main issue.

it did not check ntrip.debug as 'old values' did not have this field.
and hence when we tried to toggle ntrip.debug, we didn't actually disable ntrip which would make the first error

.clone();
.get(group, name)
.map(|x| x.value.clone())
.unwrap_or_default();
Copy link
Contributor Author

@adrian-kong adrian-kong Jan 12, 2023

Choose a reason for hiding this comment

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

this was the second issue, ntrip.enable field was not found in old values and would error here.
this now assumes the groups are off by default so we won't unset it

@adrian-kong adrian-kong changed the title settings write order bug fix [CPP-782] settings not disabled when group has changed [CPP-782] Jan 12, 2023
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.

3 participants