diff --git a/client/src/cmdhf.c b/client/src/cmdhf.c index b5c22369f..245853457 100644 --- a/client/src/cmdhf.c +++ b/client/src/cmdhf.c @@ -374,6 +374,15 @@ int CmdHFTune(const char *Cmd) { return PM3_ETIMEOUT; } + // All three modes of this command answer under the same command id + // and there is no sequence number + if ((resp.status != PM3_SUCCESS) || (resp.length != 0)) { + PrintAndLogEx(WARNING, "unexpected reply to HF initialization (status %d, %u bytes)", + resp.status, + (unsigned)resp.length + ); + } + mode[0] = 2; uint32_t v_max = 0xFFFF; @@ -390,6 +399,9 @@ int CmdHFTune(const char *Cmd) { break; } + // Anything still queued is a leftover + clearCommandBuffer(); + SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF, mode, sizeof(mode)); if (WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING_HF, &resp, 1000) == false) { PrintAndLogEx(NORMAL, ""); @@ -430,6 +442,7 @@ int CmdHFTune(const char *Cmd) { } mode[0] = 3; + clearCommandBuffer(); SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF, mode, sizeof(mode)); if (WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING_HF, &resp, 1000) == false) { PrintAndLogEx(WARNING, "timeout while waiting for Proxmark HF shutdown, aborting");