From 3e84976b55cdf7fe203ef692531f9d4769795257 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Sun, 4 Jul 2021 14:33:46 +0300 Subject: [PATCH 1/6] fix misaligned labels --- common/updates-model.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/common/updates-model.cpp b/common/updates-model.cpp index 976d724ee3..ec894b414f 100644 --- a/common/updates-model.cpp +++ b/common/updates-model.cpp @@ -84,20 +84,29 @@ void updates_model::draw(std::shared_ptr not_model, ux_wind // Draw Firmware update Pane // =========================================================================== fw_update_needed = draw_firmware_section(not_model, window_name, update, positions, window, error_message); - } else { - ImGui::PushFont(window.get_large_font()); ImGui::PushStyleColor(ImGuiCol_Text, white); - ImGui::SetCursorPos({ positions.orig_pos.x, positions.y0 - 100 }); ImGui::SetWindowFontScale(1.5); - ImGui::Text("%s","THE DEVICE HAS BEEN DISCONNECTED,"); - ImGui::SetCursorPos({ positions.orig_pos.x - 100, positions.y0 - 70 }); - ImGui::Text("%s", "PLEASE RECONNECT IT OR CLOSE THE UPDATES WINDOW."); - ImGui::PopFont(); - ImGui::SetCursorPos({ positions.orig_pos.x + 230, positions.y0 }); + std::string disconnected_text = "THE DEVICE HAS BEEN DISCONNECTED,"; + auto disconnected_text_size = ImGui::CalcTextSize(disconnected_text.c_str()); + auto disconnected_text_x_pixel = positions.w / 2 - disconnected_text_size.x / 2; // Align 2 center + auto vertical_padding = 100.f; + ImGui::SetCursorPos({ disconnected_text_x_pixel, vertical_padding }); + ImGui::Text("%s", disconnected_text.c_str()); + + std::string reconnect_text = "PLEASE RECONNECT IT OR CLOSE THE UPDATES WINDOW."; + auto reconnect_text_size = ImGui::CalcTextSize(reconnect_text.c_str()); + auto reconnect_text_x_pixel = positions.w / 2 - reconnect_text_size.x / 2; // Align 2 center + ImGui::SetCursorPosX(reconnect_text_x_pixel); + ImGui::Text("%s", reconnect_text.c_str()); + ImGui::SetWindowFontScale(3.); + + auto disconnect_icon_size = ImGui::CalcTextSize(textual_icons::lock); + auto disconnect_icon_x_pixel = (positions.w / 2.f) - (disconnect_icon_size.x / 2); // Align 2 center + ImGui::SetCursorPosX( disconnect_icon_x_pixel ); ImGui::Text("%s", static_cast(textual_icons::lock)); ImGui::SetWindowFontScale(1.); ImGui::PopStyleColor(); @@ -711,7 +720,7 @@ bool updates_model::draw_firmware_section(std::shared_ptr n } else if (_fw_update_state == fw_update_states::downloading) { - ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 }); + ImGui::SetCursorScreenPos({ pos.orig_pos.x , pos.orig_pos.y + pos.h - 95 }); _progress.draw(window, static_cast(pos.w) - 170, _fw_download_progress / 3); if (_fw_download_progress == 100 && !_fw_image.empty()) { @@ -727,7 +736,7 @@ bool updates_model::draw_firmware_section(std::shared_ptr n } else if (_fw_update_state == fw_update_states::started) { - ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 }); + ImGui::SetCursorScreenPos({ pos.orig_pos.x, pos.orig_pos.y + pos.h - 95 }); _progress.draw(window, static_cast(pos.w) - 170, static_cast(_update_manager->get_progress() * 0.66 + 33)); if (_update_manager->done()) { _fw_update_state = fw_update_states::completed; From 4b032eb1bf341fa98c39b3241eb33f7075253904 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Sun, 4 Jul 2021 15:07:06 +0300 Subject: [PATCH 2/6] remove update URL button on settings and save URL while typing --- common/viewer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/viewer.cpp b/common/viewer.cpp index 86968e4ae4..f6dfb5232a 100644 --- a/common/viewer.cpp +++ b/common/viewer.cpp @@ -2902,6 +2902,12 @@ namespace rs2 if (ImGui::RadioButton("Custom Server", !official_url)) { official_url = false; + temp_cfg.set(configurations::update::sw_updates_official_server, false); + + // Load last saved custom URL + url_str = custom_url; + temp_cfg.set(configurations::update::sw_updates_url, url_str); + } if (ImGui::IsItemHovered()) { @@ -2913,12 +2919,7 @@ namespace rs2 if (ImGui::InputText("##custom_server_url", custom_url, 255)) { url_str = custom_url; - } - ImGui::SameLine(); - if (ImGui::Button("Update URL", ImVec2(80, 20))) - { temp_cfg.set(configurations::update::sw_updates_url, url_str); - temp_cfg.set(configurations::update::sw_updates_official_server, false); } } #endif From 6ee7ffc5f673234a3da246ee466239844840a71c Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Sun, 4 Jul 2021 15:08:51 +0300 Subject: [PATCH 3/6] remove semicolon from python file --- unit-tests/py/rspy/timer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit-tests/py/rspy/timer.py b/unit-tests/py/rspy/timer.py index d915eac390..8a7aa5cb38 100644 --- a/unit-tests/py/rspy/timer.py +++ b/unit-tests/py/rspy/timer.py @@ -23,6 +23,6 @@ def has_expired(self): # Force time expiration def set_expired(self): - self._sw.reset(time.perf_counter() - (self._delta + 0.00001)); + self._sw.reset(time.perf_counter() - (self._delta + 0.00001)) From d69740d27e3c777db0b8bf4b372f0c841d2a3ace Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Mon, 5 Jul 2021 12:42:07 +0300 Subject: [PATCH 4/6] support online update of recovery device --- common/sw-update/dev-updates-profile.cpp | 65 +++++++++++++----------- common/sw-update/dev-updates-profile.h | 1 + common/updates-model.cpp | 10 ++-- common/updates-model.h | 8 +-- 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/common/sw-update/dev-updates-profile.cpp b/common/sw-update/dev-updates-profile.cpp index 252a6c2c09..4ac25184e4 100644 --- a/common/sw-update/dev-updates-profile.cpp +++ b/common/sw-update/dev-updates-profile.cpp @@ -16,6 +16,14 @@ namespace rs2 std::string dev_name = (dev.supports(RS2_CAMERA_INFO_NAME)) ? dev.get_info(RS2_CAMERA_INFO_NAME) : "Unknown"; std::string serial = (dev.supports(RS2_CAMERA_INFO_SERIAL_NUMBER)) ? dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER) : "Unknown"; + + std::string fw_update_id = "Unknown"; + + if (dev.supports(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID)) + { + fw_update_id = dev.get_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID); + } + std::string firmware_ver = (dev.supports(RS2_CAMERA_INFO_FIRMWARE_VERSION)) ? dev.get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION) : "0.0.0"; _update_profile.software_version = sw_update::version(RS2_API_FULL_VERSION_STR); @@ -25,6 +33,7 @@ namespace rs2 _update_profile.device_name = dev_name; _update_profile.serial_number = serial; + _update_profile.fw_update_id = fw_update_id; } bool dev_updates_profile::retrieve_updates(component_part_type comp, bool& fail_access_db) @@ -38,47 +47,43 @@ namespace rs2 bool update_available(false); - // We expect to get here in recovery mode (on firmware update flow) and therefore do not want to throw... - if (_update_profile.device_name.find("Recovery") == std::string::npos) - { - auto &versions_vec((comp == FIRMWARE) ? - _update_profile.firmware_versions : _update_profile.software_versions); + auto &versions_vec((comp == FIRMWARE) ? + _update_profile.firmware_versions : _update_profile.software_versions); - version& current_version((comp == FIRMWARE) ? _update_profile.firmware_version : _update_profile.software_version); + version& current_version((comp == FIRMWARE) ? _update_profile.firmware_version : _update_profile.software_version); + { + version_info experimental_update; + auto parse_update_stts = try_parse_update(_versions_db, _update_profile.device_name, EXPERIMENTAL, comp, experimental_update); + if ( parse_update_stts == VERSION_FOUND) { - version_info experimental_update; - auto parse_update_stts = try_parse_update(_versions_db, _update_profile.device_name, EXPERIMENTAL, comp, experimental_update); - if ( parse_update_stts == VERSION_FOUND) + if (current_version < experimental_update.ver) { - if (current_version < experimental_update.ver) - { - versions_vec[experimental_update.ver] = experimental_update; - update_available = true; - } + versions_vec[experimental_update.ver] = experimental_update; + update_available = true; } + } - version_info recommened_update; - if (try_parse_update(_versions_db, _update_profile.device_name, RECOMMENDED, comp, recommened_update) == VERSION_FOUND) + version_info recommened_update; + if (try_parse_update(_versions_db, _update_profile.device_name, RECOMMENDED, comp, recommened_update) == VERSION_FOUND) + { + if (current_version < recommened_update.ver) { - if (current_version < recommened_update.ver) - { - versions_vec[recommened_update.ver] = recommened_update; - update_available = true; - } + versions_vec[recommened_update.ver] = recommened_update; + update_available = true; } + } - version_info required_update; - if (try_parse_update(_versions_db, _update_profile.device_name, ESSENTIAL, comp, required_update) == VERSION_FOUND) + version_info required_update; + if (try_parse_update(_versions_db, _update_profile.device_name, ESSENTIAL, comp, required_update) == VERSION_FOUND) + { + if (current_version < required_update.ver) { - if (current_version < required_update.ver) - { - versions_vec[required_update.ver] = required_update; - update_available = true; - } + versions_vec[required_update.ver] = required_update; + update_available = true; } - - fail_access_db = (parse_update_stts == DB_LOAD_FAILURE); } + + fail_access_db = (parse_update_stts == DB_LOAD_FAILURE); } return update_available; } diff --git a/common/sw-update/dev-updates-profile.h b/common/sw-update/dev-updates-profile.h index e826bb5c30..b9cceb4eb8 100644 --- a/common/sw-update/dev-updates-profile.h +++ b/common/sw-update/dev-updates-profile.h @@ -34,6 +34,7 @@ namespace rs2 { std::string device_name; std::string serial_number; + std::string fw_update_id; sw_update::version software_version; sw_update::version firmware_version; diff --git a/common/updates-model.cpp b/common/updates-model.cpp index ec894b414f..9e8db217b5 100644 --- a/common/updates-model.cpp +++ b/common/updates-model.cpp @@ -72,8 +72,12 @@ void updates_model::draw(std::shared_ptr not_model, ux_wind bool sw_update_needed(false), fw_update_needed(false); - // Verify Device Exists - if (update.profile.dev_active || _fw_update_state == fw_update_states::started) + bool fw_update_in_process = _fw_update_state == fw_update_states::started + || _fw_update_state == fw_update_states::failed_updating + || _fw_update_state == fw_update_states::failed_downloading; + + // Verify Device Exists or a FW update process + if (update.profile.dev_active || fw_update_in_process) { // =========================================================================== // Draw Software update Pane @@ -86,7 +90,7 @@ void updates_model::draw(std::shared_ptr not_model, ux_wind fw_update_needed = draw_firmware_section(not_model, window_name, update, positions, window, error_message); } else - { + { // Indicate device disconnected to the user ImGui::PushStyleColor(ImGuiCol_Text, white); ImGui::SetWindowFontScale(1.5); std::string disconnected_text = "THE DEVICE HAS BEEN DISCONNECTED,"; diff --git a/common/updates-model.h b/common/updates-model.h index e7603786bd..adeaaf7547 100644 --- a/common/updates-model.h +++ b/common/updates-model.h @@ -31,7 +31,7 @@ namespace rs2 { std::lock_guard lock(_lock); auto it = std::find_if(_updates.begin(), _updates.end(), [&](update_profile_model& p) { - return (p.profile.device_name == update.profile.device_name && p.profile.serial_number == update.profile.serial_number); + return (p.profile.fw_update_id == update.profile.fw_update_id); }); if (it == _updates.end()) _updates.push_back(update); @@ -45,7 +45,7 @@ namespace rs2 { std::lock_guard lock(_lock); auto it = std::find_if(_updates.begin(), _updates.end(), [&](update_profile_model& p) { - return (p.profile.device_name == update.profile.device_name && p.profile.serial_number == update.profile.serial_number); + return (p.profile.fw_update_id == update.profile.fw_update_id); }); if (it != _updates.end()) { @@ -56,7 +56,7 @@ namespace rs2 { std::lock_guard lock(_lock); auto it = std::find_if(_updates.begin(), _updates.end(), [&](update_profile_model& p) { - return (p.profile.device_name == update.device_name && p.profile.serial_number == update.serial_number); + return (p.profile.fw_update_id == update.fw_update_id); }); if (it != _updates.end()) _updates.erase(it); @@ -69,7 +69,7 @@ namespace rs2 { std::lock_guard lock(_lock); auto it = std::find_if(_updates.begin(), _updates.end(), [&](update_profile_model& p) { - return (p.profile.device_name == update.device_name && p.profile.serial_number == update.serial_number); + return (p.profile.fw_update_id == update.fw_update_id); }); if (it != _updates.end()) it->profile.dev_active = active; From f12eb9839634912d66a6001ab73be74005a41bb2 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Mon, 5 Jul 2021 13:29:59 +0300 Subject: [PATCH 5/6] UI alignment of updates window progress bar --- common/updates-model.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/common/updates-model.cpp b/common/updates-model.cpp index 9e8db217b5..7022ff3503 100644 --- a/common/updates-model.cpp +++ b/common/updates-model.cpp @@ -513,7 +513,9 @@ bool updates_model::draw_firmware_section(std::shared_ptr n } - ImVec2 fw_text_pos(pos.orig_pos.x + 10, pos.mid_y + 15); + auto left_padding = 10; + auto top_padding = 15; + ImVec2 fw_text_pos(pos.orig_pos.x + left_padding, pos.mid_y + top_padding); ImGui::SetCursorScreenPos(fw_text_pos); ImGui::PushFont(window.get_large_font()); @@ -724,8 +726,8 @@ bool updates_model::draw_firmware_section(std::shared_ptr n } else if (_fw_update_state == fw_update_states::downloading) { - ImGui::SetCursorScreenPos({ pos.orig_pos.x , pos.orig_pos.y + pos.h - 95 }); - _progress.draw(window, static_cast(pos.w) - 170, _fw_download_progress / 3); + ImGui::SetCursorScreenPos({ pos.orig_pos.x + left_padding, pos.orig_pos.y + pos.h - 95 }); + _progress.draw(window, static_cast(pos.w) - 170 - left_padding, _fw_download_progress / 3); if (_fw_download_progress == 100 && !_fw_image.empty()) { _fw_download_progress = 0; @@ -740,8 +742,8 @@ bool updates_model::draw_firmware_section(std::shared_ptr n } else if (_fw_update_state == fw_update_states::started) { - ImGui::SetCursorScreenPos({ pos.orig_pos.x, pos.orig_pos.y + pos.h - 95 }); - _progress.draw(window, static_cast(pos.w) - 170, static_cast(_update_manager->get_progress() * 0.66 + 33)); + ImGui::SetCursorScreenPos({ pos.orig_pos.x + left_padding, pos.orig_pos.y + pos.h - 95 }); + _progress.draw(window, static_cast(pos.w) - 170 - left_padding, static_cast(_update_manager->get_progress() * 0.66 + 33)); if (_update_manager->done()) { _fw_update_state = fw_update_states::completed; _fw_image.clear(); @@ -763,12 +765,12 @@ bool updates_model::draw_firmware_section(std::shared_ptr n else if (_fw_update_state == fw_update_states::failed_downloading || _fw_update_state == fw_update_states::failed_updating) { - ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 }); + ImGui::SetCursorScreenPos({ pos.orig_pos.x + left_padding, pos.orig_pos.y + pos.h - 95 }); ImGui::PushStyleColor(ImGuiCol_Text, white); std::string text = _fw_update_state == fw_update_states::failed_downloading ? "Firmware download failed, check connection and press to retry" : "Firmware update process failed, press to retry"; - if (ImGui::Button(text.c_str(), ImVec2(pos.w - 170, 25))) + if (ImGui::Button(text.c_str(), ImVec2(pos.w - 170 - left_padding, 25))) { _fw_update_state = fw_update_states::ready; _update_manager.reset(); From bb3f4f490ad6a19e6fd2e1b5d542280c8c836b6b Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Mon, 5 Jul 2021 13:44:59 +0300 Subject: [PATCH 6/6] fix displaying 0 as FW version when entering DFU mode --- common/updates-model.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/updates-model.cpp b/common/updates-model.cpp index 7022ff3503..fa873263d4 100644 --- a/common/updates-model.cpp +++ b/common/updates-model.cpp @@ -573,7 +573,15 @@ bool updates_model::draw_firmware_section(std::shared_ptr n ImGui::Text("%s", "Current FW version:"); ImGui::SameLine(); ImGui::PopStyleColor(); - auto current_fw_ver_str = std::string(selected_profile.profile.firmware_version); + + // During FW update do not take the version from the device because a recovery device version is 0.0.0.0. + // Instead display an update in progress label + std::string current_fw_ver_str; + if (_fw_update_state != fw_update_states::started) + current_fw_ver_str = std::string(selected_profile.profile.firmware_version); + else + current_fw_ver_str = "Update in progress.."; + ImGui::Text("%s", current_fw_ver_str.c_str());