Skip to content

Conversation

john-michaelburke
Copy link
Collaborator

@john-michaelburke john-michaelburke commented Sep 4, 2021

Implements

  • Update Tab (Limited Backend, for the most part 100% frontend logic)
  • Update Downloader

Update Tab Backend Functionality:

  • Downloads newest firmware and checks for latest version
  • Compares version current vs latest to decide whether or not to allow upgrading. Currently hardcode current version until Settings available.
  • Commits firmware file to flash memory and resets piksi. Update tab maintains state when the piksi comes back online.

@john-michaelburke john-michaelburke force-pushed the john-michaelburke/update_tab2 branch 5 times, most recently from a6722f4 to ebd3a89 Compare September 7, 2021 21:45
@john-michaelburke john-michaelburke force-pushed the john-michaelburke/update_tab2 branch from ebd3a89 to bf72ffe Compare September 7, 2021 22:46
@john-michaelburke john-michaelburke force-pushed the john-michaelburke/update_tab2 branch from bf72ffe to b704a4b Compare September 7, 2021 23:05
@john-michaelburke john-michaelburke requested a review from a team September 8, 2021 00:09
@john-michaelburke john-michaelburke changed the title Update Tab + Update Downloader[CPP-46][CPP-47][CPP-296] Update Tab + Update Downloader[CPP-46][CPP-47][CPP-296][CPP-303] Sep 8, 2021
@john-michaelburke john-michaelburke force-pushed the john-michaelburke/update_tab2 branch 3 times, most recently from 78f88a1 to b66ae41 Compare September 9, 2021 02:53
@john-michaelburke john-michaelburke force-pushed the john-michaelburke/update_tab2 branch from b66ae41 to f9905bc Compare September 9, 2021 02:54
@john-michaelburke
Copy link
Collaborator Author

Alright @silverjam I think this is ready to go now. Seeing as how I'll be adding more to this tab this sprint, I will push off unittests until I have a few more features in the bag. Probably won't be able to test much unless we mock a device or set up one on a self hosted runner.

https://swift-nav.atlassian.net/browse/CPP-312

.collect();
let text = text.split('\n').collect::<Vec<&str>>();
let final_text = if text.len() > 1 {
// upgrade tool deliminates lines in stoud with \r, we want penultimate line that is complete to show
Copy link
Contributor

Choose a reason for hiding this comment

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

The intent for sending '\r' is for the line being sent to erase the previous line, I believe the old console emulated this terminal like behavior, but not sure. We don't need to implement that behavior now, but might be something we should do later.

EDIT: looks like we might already be emulating that behavior with FirmwareUpgradePaneLogger?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I think the only spot this '\r' logic is used in the old console is in this exact spot to discern which line is the log we are interested in. The old console also has separate functions for either simply appending to the log pane or replacing the previous log before appending. So aside from the broken log messages from the piksi I believe this is working as intended.

if update.download_latest_firmware && !update_shared.downloading() {
if let Some(update_downloader_thread) = update_downloader_thread.take()
{
update_downloader_thread.join().expect(THREAD_JOIN_FAILURE);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the intent of this code? If we aren't downloading, then the download thread should be gone, correct? Why do we need to join on the thread before we can replace the thread handle? I would think we don't really need the thread handle at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed. You are correct. I think this was just out of habit for joining all threads.

};
update_shared.set_firmware_local_filepath(filepath);
update_shared.set_downloading(false);
log::logger().flush();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we flushing the log?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed. We have had odd behavior with the logger not flushing in separate threads at least in our server.rs file. I thought it was related to separate threads but it may be related to trying to flush in a pyo3 module instead. I tested it and the logs look fine to me without the flush.

/// Returns:
/// - `true` if the later_version is greater than the early version.
/// - `false` if the later_version is not greater than the early version.
pub fn compare_semvers(early_version: String, later_version: String) -> anyhow::Result<bool> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably fine to keep this, but FYI there's a semver crate: https://docs.rs/semver/1.0.4/semver/struct.Version.html -- I doubt it'd directly handle our "dev" versions though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did swap it out. It does appear to handle dev versions but quite methodically i.e. 1.2.3-dev123 < 1.2.3-dev543. I think this should be reasonable though.

if !shared_state.is_running() {
if let Err(e) = tabs.main.lock().unwrap().end_csv_logging() {
error!("Issue closing csv file, {}", e);
let update_shared = tabs
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we rename this to update_tab_context (or update_tab_ctx) too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

.update
.lock()
.expect(UNABLE_TO_CLONE_UPDATE_SHARED)
.update_tab_context_clone();
Copy link
Contributor

@silverjam silverjam Sep 9, 2021

Choose a reason for hiding this comment

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

I'd like to follow the convention with <verb>_<thing> naming for our methods, so clone_update_tab_context instead of update_tab_context_clone

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. I will take note and follow this for the future. Can also do a pass through in the future to clean up some of these naming schemes we have at least make things consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good

}
sleep(Duration::from_millis(PAUSE_LOOP_SLEEP_DURATION_MS));
}
log::logger().flush();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove this flush too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No it looks like this flush is needed or we only get updates every 5-10seconds

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@john-michaelburke john-michaelburke merged commit e7a9776 into main Sep 9, 2021
@john-michaelburke john-michaelburke deleted the john-michaelburke/update_tab2 branch September 9, 2021 22:45
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