fancy timers

This commit is contained in:
Philippe Teuwen 2020-05-13 23:20:46 +02:00
commit 6a006677ef
2 changed files with 11 additions and 9 deletions

View file

@ -1671,19 +1671,21 @@ int CmdTuneSamples(const char *Cmd) {
RepaintGraphWindow(); RepaintGraphWindow();
int timeout = 0; int timeout = 0;
int timeout_max = 20;
PrintAndLogEx(INFO, "Measuring antenna characteristics, please wait..."); PrintAndLogEx(INFO, "Measuring antenna characteristics, please wait...");
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING, NULL, 0); SendCommandNG(CMD_MEASURE_ANTENNA_TUNING, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
while (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING, &resp, 2000)) { PrintAndLogEx(INPLACE, "% 3i", timeout_max - timeout);
timeout++; while (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING, &resp, 500)) {
printf(".");
fflush(stdout); fflush(stdout);
if (timeout > 7) { if (timeout >= timeout_max) {
PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting..."); PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting...");
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
timeout++;
PrintAndLogEx(INPLACE, "% 3i", timeout_max - timeout);
} }
if (resp.status != PM3_SUCCESS) { if (resp.status != PM3_SUCCESS) {
@ -1728,7 +1730,7 @@ int CmdTuneSamples(const char *Cmd) {
else else
sprintf(judgement, _GREEN_("OK")); 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_("[+]") , (package->peak_v < LF_UNUSABLE_V) ? _CYAN_("[!]") : _GREEN_("[+]")
, judgement , judgement
); );
@ -1746,7 +1748,7 @@ int CmdTuneSamples(const char *Cmd) {
else else
sprintf(judgement, _GREEN_("OK")); 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_("[+]") , (package->v_hf < HF_UNUSABLE_V) ? _CYAN_("[!]") : _GREEN_("[+]")
, judgement , judgement
); );

View file

@ -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); PrintAndLogEx(SUCCESS, "Waiting for Proxmark3 to appear on " _YELLOW_("%s"), portname);
fflush(stdout); fflush(stdout);
int openCount = 0; int openCount = 0;
PrintAndLogEx(INPLACE, ""); PrintAndLogEx(INPLACE, "% 3i", timeout);
do { do {
sp = uart_open(portname, speed); sp = uart_open(portname, speed);
msleep(500); msleep(500);
printf("."); PrintAndLogEx(INPLACE, "% 3i", timeout - openCount -1);
fflush(stdout);
} while (++openCount < timeout && (sp == INVALID_SERIAL_PORT || sp == CLAIMED_SERIAL_PORT)); } while (++openCount < timeout && (sp == INVALID_SERIAL_PORT || sp == CLAIMED_SERIAL_PORT));
} }