From 6a006677ef527d09d49af2bb6e61b3de7ac9835a Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Wed, 13 May 2020 23:20:46 +0200 Subject: [PATCH] fancy timers --- client/src/cmddata.c | 14 ++++++++------ client/src/comms.c | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 9125184be..d85271c85 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -1671,19 +1671,21 @@ int CmdTuneSamples(const char *Cmd) { RepaintGraphWindow(); int timeout = 0; + int timeout_max = 20; PrintAndLogEx(INFO, "Measuring antenna characteristics, please wait..."); clearCommandBuffer(); SendCommandNG(CMD_MEASURE_ANTENNA_TUNING, NULL, 0); PacketResponseNG resp; - while (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING, &resp, 2000)) { - timeout++; - printf("."); + PrintAndLogEx(INPLACE, "% 3i", timeout_max - timeout); + while (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING, &resp, 500)) { fflush(stdout); - if (timeout > 7) { + if (timeout >= timeout_max) { PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting..."); return PM3_ETIMEOUT; } + timeout++; + PrintAndLogEx(INPLACE, "% 3i", timeout_max - timeout); } if (resp.status != PM3_SUCCESS) { @@ -1728,7 +1730,7 @@ int CmdTuneSamples(const char *Cmd) { else sprintf(judgement, _GREEN_("OK")); - PrintAndLogEx(NORMAL, "%sLF antenna is %s \n" + PrintAndLogEx(NORMAL, "%s LF antenna is %s \n" , (package->peak_v < LF_UNUSABLE_V) ? _CYAN_("[!]") : _GREEN_("[+]") , judgement ); @@ -1746,7 +1748,7 @@ int CmdTuneSamples(const char *Cmd) { else sprintf(judgement, _GREEN_("OK")); - PrintAndLogEx(NORMAL, "%sHF antenna is %s" + PrintAndLogEx(NORMAL, "%s HF antenna is %s" , (package->v_hf < HF_UNUSABLE_V) ? _CYAN_("[!]") : _GREEN_("[+]") , judgement ); diff --git a/client/src/comms.c b/client/src/comms.c index 4c0a8d990..eb4548ecd 100644 --- a/client/src/comms.c +++ b/client/src/comms.c @@ -547,12 +547,12 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, PrintAndLogEx(SUCCESS, "Waiting for Proxmark3 to appear on " _YELLOW_("%s"), portname); fflush(stdout); int openCount = 0; - PrintAndLogEx(INPLACE, ""); + PrintAndLogEx(INPLACE, "% 3i", timeout); do { sp = uart_open(portname, speed); msleep(500); - printf("."); - fflush(stdout); + PrintAndLogEx(INPLACE, "% 3i", timeout - openCount -1); + } while (++openCount < timeout && (sp == INVALID_SERIAL_PORT || sp == CLAIMED_SERIAL_PORT)); }