aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmi-firmware-update
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-01-16 13:04:49 +0100
committerAleksander Morgado <aleksander@aleksander.es>2017-01-16 13:13:56 +0100
commitb50239d2f53c5f00bddf51ca820efd11ca0bcfcb (patch)
tree542a8e46561d9db66460ae73dddf7ed7985f9070 /src/qmi-firmware-update
parentc10a0338dec90704871206b8f7fc76fe8779c8d4 (diff)
downloadexternal_libqmi-b50239d2f53c5f00bddf51ca820efd11ca0bcfcb.zip
external_libqmi-b50239d2f53c5f00bddf51ca820efd11ca0bcfcb.tar.gz
external_libqmi-b50239d2f53c5f00bddf51ca820efd11ca0bcfcb.tar.bz2
qmi-firmware-update: improve stdout progress reporting
Diffstat (limited to 'src/qmi-firmware-update')
-rw-r--r--src/qmi-firmware-update/qfu-updater.c62
1 files changed, 47 insertions, 15 deletions
diff --git a/src/qmi-firmware-update/qfu-updater.c b/src/qmi-firmware-update/qfu-updater.c
index 883432c..267c4ee 100644
--- a/src/qmi-firmware-update/qfu-updater.c
+++ b/src/qmi-firmware-update/qfu-updater.c
@@ -58,6 +58,21 @@ struct _QfuUpdaterPrivate {
};
/******************************************************************************/
+
+static const gchar *progress[] = {
+ "(*-----)",
+ "(-*----)",
+ "(--*---)",
+ "(---*--)",
+ "(----*-)",
+ "(-----*)",
+ "(----*-)",
+ "(---*--)",
+ "(--*---)",
+ "(-*----)"
+};
+
+/******************************************************************************/
/* Run */
/* Wait time after the upgrade has been done, before using the cdc-wdm port */
@@ -117,6 +132,9 @@ typedef struct {
gchar *firmware_version;
gchar *config_version;
gchar *carrier;
+
+ /* Waiting for boot */
+ guint wait_for_boot_seconds_elapsed;
} RunContext;
static void
@@ -220,6 +238,8 @@ run_context_step_qmi_client_after (GTask *task)
ctx = (RunContext *) g_task_get_task_data (task);
self = g_task_get_source_object (task);
+ g_print ("loading device information after the update...\n");
+
g_debug ("[qfu-updater] creating QMI DMS client after upgrade...");
g_assert (ctx->cdc_wdm_file);
qfu_utils_new_client_dms (ctx->cdc_wdm_file,
@@ -237,6 +257,18 @@ wait_for_boot_ready (GTask *task)
RunContext *ctx;
ctx = (RunContext *) g_task_get_task_data (task);
+ ctx->wait_for_boot_seconds_elapsed++;
+
+ if (ctx->wait_for_boot_seconds_elapsed < WAIT_FOR_BOOT_TIMEOUT_SECS) {
+ if (!qfu_log_get_verbose_stdout ())
+ g_print (CLEAR_LINE "%s %u",
+ progress[ctx->wait_for_boot_seconds_elapsed % G_N_ELEMENTS (progress)],
+ WAIT_FOR_BOOT_TIMEOUT_SECS - ctx->wait_for_boot_seconds_elapsed);
+ return G_SOURCE_CONTINUE;
+ }
+
+ if (!qfu_log_get_verbose_stdout ())
+ g_print (CLEAR_LINE);
/* Go on */
run_context_step_next (task, ctx->step + 1);
@@ -246,8 +278,15 @@ wait_for_boot_ready (GTask *task)
static void
run_context_step_wait_for_boot (GTask *task)
{
- g_debug ("[qfu-updater] waiting some time before accessing the cdc-wdm device...");
- g_timeout_add_seconds (WAIT_FOR_BOOT_TIMEOUT_SECS, (GSourceFunc) wait_for_boot_ready, task);
+ g_debug ("[qfu-updater] waiting some time (%us) before accessing the cdc-wdm device...",
+ WAIT_FOR_BOOT_TIMEOUT_SECS);
+
+ if (!qfu_log_get_verbose_stdout ()) {
+ g_print ("waiting some time for the device to boot...\n");
+ g_print ("%s %u", progress[0], WAIT_FOR_BOOT_TIMEOUT_SECS);
+ }
+
+ g_timeout_add_seconds (1, (GSourceFunc) wait_for_boot_ready, task);
}
static void
@@ -274,6 +313,8 @@ wait_for_cdc_wdm_ready (QfuDeviceSelection *device_selection,
g_debug ("[qfu-updater] cdc-wdm device found: %s", path);
g_free (path);
+ g_print ("normal mode detected\n");
+
/* Go on */
run_context_step_next (task, ctx->step + 1);
}
@@ -342,19 +383,6 @@ run_context_step_cleanup_image (GTask *task)
run_context_step_next (task, ctx->step + 1);
}
-static const gchar *progress[] = {
- "(*-----)",
- "(-*----)",
- "(--*---)",
- "(---*--)",
- "(----*-)",
- "(-----*)",
- "(----*-)",
- "(---*--)",
- "(--*---)",
- "(-*----)"
-};
-
static void
run_context_step_download_image (GTask *task)
{
@@ -503,6 +531,8 @@ wait_for_tty_ready (QfuDeviceSelection *device_selection,
g_debug ("[qfu-updater] TTY device found: %s", path);
g_free (path);
+ g_print ("download mode detected\n");
+
/* Go on */
run_context_step_next (task, ctx->step + 1);
}
@@ -1018,6 +1048,8 @@ run_context_step_qmi_client (GTask *task)
ctx = (RunContext *) g_task_get_task_data (task);
self = g_task_get_source_object (task);
+ g_print ("loading device information before the update...\n");
+
g_debug ("[qfu-updater] creating QMI DMS client...");
g_assert (ctx->cdc_wdm_file);
qfu_utils_new_client_dms (ctx->cdc_wdm_file,