10 #include <condition_variable> 19 #include "common/fw/D4XX_FW_Image.h" 20 #include "common/fw/SR3XX_FW_Image.h" 21 #include "common/fw/L5XX_FW_Image.h" 23 #define FW_D4XX_FW_IMAGE_VERSION "" 24 #define FW_SR3XX_FW_IMAGE_VERSION "" 25 #define FW_L5XX_FW_IMAGE_VERSION "" 32 constexpr
const char*
recommended_fw_url =
"https://dev.intelrealsense.com/docs/firmware-updates";
71 std::map<int, std::vector<uint8_t>> rv;
77 auto vec = std::vector<uint8_t>(hex, hex +
size);
85 auto vec = std::vector<uint8_t>(hex, hex +
size);
93 auto vec = std::vector<uint8_t>(hex, hex +
size);
105 auto str = fw + delimiter;
106 while ((pos =
str.find(delimiter)) != std::string::npos) {
107 auto s =
str.substr(0, pos);
110 str.erase(0, pos + delimiter.length());
117 if (curr ==
"" || available ==
"")
return false;
119 size_t fw_string_size = 4;
122 if (
a.size() != fw_string_size ||
c.size() != fw_string_size)
125 for (
int i = 0;
i < fw_string_size;
i++) {
135 std::function<
bool()>
action, std::function<
void()> cleanup,
136 std::chrono::system_clock::duration delta)
148 if (
action())
return true;
156 catch (
const std::exception& ex)
164 fail(
"Unknown error during update.\nPlease reconnect the camera to exit recovery mode");
170 this_thread::sleep_for(milliseconds(100));
176 std::function<
void()> cleanup,
190 []( std::shared_ptr< notification_model >
n ) {
203 int next_progress = 10;
209 log(
"Backing-up camera flash memory");
214 auto flash = upd.create_flash_backup([&](
const float progress)
216 _progress = int((ceil(progress * 5) / 5) * (30 - next_progress)) + next_progress;
224 file.write((
const char*)flash.data(), flash.size());
225 log_backup_status =
"Backup completed and saved as '" + temp +
"'";
228 catch (
const std::exception&
e)
232 log_backup_status =
"WARNING: backup failed; continuing without it...";
236 log_backup_status +
", Error: " + e.what());
243 log_backup_status =
"WARNING: backup failed; continuing without it...";
244 not_model_protected->add_log(log_backup_status +
", Unknown error occurred");
248 log(log_backup_status);
254 log(
"Requesting to switch to recovery mode");
259 upd.enter_update_state();
261 std::this_thread::sleep_for(std::chrono::seconds(2));
283 catch (std::exception &e) {
289 to_string() <<
"Exception caught in FW Update process-flow: " << e.what() <<
"; Retrying...");
296 }, cleanup, std::chrono::seconds(60)))
298 fail(
"Recovery device did not connect in time!");
312 log(
"Recovery device connected, starting update");
316 _progress = int((ceil(progress * 10) / 10 * (90 - next_progress)) + next_progress);
319 log(
"Firmware Download completed, await DFU transition event");
320 std::this_thread::sleep_for(std::chrono::seconds(3));
321 log(
"Firmware Update completed, waiting for device to reconnect");
328 _progress = int((ceil(progress * 10) / 10 * (90 - next_progress)) + next_progress);
330 log(
"Firmware Update completed, waiting for device to reconnect");
347 log(
"Discovered connection of the original device");
356 }, cleanup, std::chrono::seconds(60)))
358 fail(
"Original device did not reconnect in time!");
362 log(
"Device reconnected succesfully!");
376 ImVec4 shadow{ 1.f, 1.f, 1.f, 0.1f };
393 ImGui::Text(
"Firmware updates offer critical bug fixes and\nunlock new camera capabilities.");
395 ImGui::Text(
"Firmware update is underway...\nPlease do not disconnect the device");
412 ImGui::Text(
"Camera Firmware Updated Successfully");
417 const auto bar_width =
width - 115;
428 if (
ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }) || update_manager->started())
432 std::for_each(fw_update_manager->get_device_model().subdevices.begin(),
433 fw_update_manager->get_device_model().subdevices.end(),
434 [&](
const std::shared_ptr<subdevice_model>& sm)
440 sm->stop(fw_update_manager->get_protected_notification_model());
450 auto _this = shared_from_this();
451 auto invoke = [_this](std::function<void()>
action) {
455 if (!update_manager->started())
456 update_manager->start(invoke);
459 enable_dismiss =
false;
471 if (update_manager->done())
480 if (update_manager->failed())
482 update_manager->check_error(error_message);
488 draw_progress_bar(win, bar_width);
507 if (
ImGui::Button(button_name.c_str(), { float(bar_width), 20 }))
538 if (update_manager->failed()) title +=
" Failed";
544 std::string progress_str =
to_string() <<
"Progress: " << update_manager->get_progress() <<
"%";
549 draw_progress_bar(win, 490);
552 auto s = update_manager->get_log();
558 if (visible || update_manager->done() || update_manager->failed())
562 if (update_manager->done() || update_manager->failed())
619 std::shared_ptr<firmware_update_manager> manager,
bool exp)
void draw_text(int x, int y, const char *text)
std::vector< std::shared_ptr< notification_model > > related_notifications
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
static const ImVec4 transparent
GLenum GLuint GLenum GLsizei const GLchar * message
static const ImVec4 white
IMGUI_API void AddRectFilled(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners=0x0F)
virtual void set_color_scheme(float t) const
GLenum GLuint GLenum severity
IMGUI_API void SetTooltip(const char *fmt,...) IM_PRINTFARGS(1)
GLuint const GLchar * name
ImVec4 saturate(const ImVec4 &a, float f)
std::vector< sensor > query_sensors() const
bool check_for(std::function< bool()> action, std::function< void()> cleanup, std::chrono::system_clock::duration delta)
IMGUI_API bool InputTextMultiline(const char *label, char *buf, size_t buf_size, const ImVec2 &size=ImVec2(0, 0), ImGuiInputTextFlags flags=0, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
static const ImVec4 light_grey
static config_file & instance()
static const ImVec4 light_blue
device_list query_devices() const
const char * fw_get_L5XX_FW_Image(int)
std::string get_folder_path(special_folder f)
static const textual_icon throphy
void update_unsigned(const std::vector< uint8_t > &image, int update_mode=RS2_UNSIGNED_UPDATE_MODE_UPDATE) const
std::string get_timestamped_file_name()
fw_update_notification_model(std::string name, std::shared_ptr< firmware_update_manager > manager, bool expaned)
GLsizei const GLchar *const * string
constexpr const char * recommended_fw_url
void draw_content(ux_window &win, int x, int y, float t, std::string &error_message) override
GLboolean GLboolean GLboolean GLboolean a
T get_or_default(const char *key, T def) const
std::vector< int > parse_fw_version(const std::string &fw)
std::function< void(std::function< void()>)> invoker
std::string error_to_string(const error &e)
IMGUI_API ImDrawList * GetWindowDrawList()
IMGUI_API void PopStyleVar(int count=1)
#define FW_SR3XX_FW_IMAGE_VERSION
static const ImVec4 regular_blue
void open_url(const char *url)
void process_flow(std::function< void()> cleanup, invoker invoke) override
#define RS2_PRODUCT_LINE_D400
const char * fw_get_SR3XX_FW_Image(int)
const char * get_info(rs2_camera_info info) const
GLint GLsizei GLsizei height
static const ImVec4 sensor_bg
void draw_expanded(ux_window &win, std::string &error_message) override
IMGUI_API void SetCursorPosX(float x)
static const ImVec4 sensor_header_light_blue
IMGUI_API void Text(const char *fmt,...) IM_PRINTFARGS(1)
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
void log(std::string line)
#define RS2_PRODUCT_LINE_L500
rs2_notification_category category
IMGUI_API void EndPopup()
const char * fw_get_D4XX_FW_Image(int)
ImVec4 alpha(const ImVec4 &v, float a)
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4 &col)
bool supports(rs2_camera_info info) const
IMGUI_API void PushFont(ImFont *font)
bool is_recommended_fw_available(std::string id)
std::map< int, std::vector< uint8_t > > create_default_fw_table()
int parse_product_line(std::string id)
#define FW_D4XX_FW_IMAGE_VERSION
const GLuint GLenum const void * binary
void set_color_scheme(float t) const override
IMGUI_API bool BeginPopupModal(const char *name, bool *p_open=NULL, ImGuiWindowFlags extra_flags=0)
IMGUI_API void SetCursorScreenPos(const ImVec2 &pos)
int stoi(const std::string &value)
std::shared_ptr< notifications_model > get_protected_notification_model()
std::string get_available_firmware_version(int product_line)
IMGUI_API void CloseCurrentPopup()
ImFont * get_large_font() const
IMGUI_API void OpenPopup(const char *str_id)
bool is_upgradeable(const std::string &curr, const std::string &available)
void fail(std::string error)
#define FW_L5XX_FW_IMAGE_VERSION
int calc_height() override
#define RS2_PRODUCT_LINE_SR300
IMGUI_API bool IsItemHovered()
std::vector< uint8_t > _fw
static const char * allow_rc_firmware
IMGUI_API void PopStyleColor(int count=1)
std::string to_string(T value)