-
Notifications
You must be signed in to change notification settings - Fork 2
Update Tab + Update Downloader[CPP-46][CPP-47][CPP-296][CPP-303] #110
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
Conversation
a6722f4
to
ebd3a89
Compare
ebd3a89
to
bf72ffe
Compare
bf72ffe
to
b704a4b
Compare
78f88a1
to
b66ae41
Compare
b66ae41
to
f9905bc
Compare
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. |
.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 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
console_backend/src/update_tab.rs
Outdated
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Co-authored-by: Jason Mobarak <[email protected]>
Co-authored-by: Jason Mobarak <[email protected]>
Co-authored-by: Jason Mobarak <[email protected]>
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
Co-authored-by: Jason Mobarak <[email protected]>
} | ||
sleep(Duration::from_millis(PAUSE_LOOP_SLEEP_DURATION_MS)); | ||
} | ||
log::logger().flush(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Implements
Update Tab Backend Functionality: