From 1e2faf0e6cc273c86a3a499b64348d6e6333549c Mon Sep 17 00:00:00 2001 From: Niel Nielsen Date: Thu, 3 Sep 2026 13:59:14 +0200 Subject: [PATCH] Update cmdhw.c Signed-off-by: Niel Nielsen --- client/src/cmdhw.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index cf4c1b845..54e4e1528 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -2294,6 +2294,16 @@ static int CmdPM5QCTest(const char *Cmd) { return PM3_SUCCESS; } +void progressbar(long sent, long total, int style) { + int percent = (int)((double)sent / total * 100); + + // Use \r at the start to move the cursor back to the beginning of the line + printf("\rProgress: [%d%%]", percent); + + // Force stdout to print immediately without waiting for a newline + fflush(stdout); +} + // One full OTA attempt: BEGIN -> WRITE... -> END. The BWM OTA has no resume // (DEV.md 8.4): a dropped chunk can't be re-sent, so any failure here means the // caller must restart the whole thing. @@ -2338,7 +2348,8 @@ static int bwm_ota_once(const uint8_t *fw, size_t fwlen) { return PM3_EFAILED; } sent += n; - print_progress(sent, fwlen, STYLE_MIXED); + progressbar(sent, fwlen, STYLE_MIXED); + printf("\n"); ///// DEBUG TEST FOR USB timeout msleep(10); }