From 1a620c5563d5c97327df0866869ada3dc68590ca Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Wed, 6 Jul 2022 19:41:08 +0300 Subject: [PATCH] add timeout and some debug messages --- armsrc/hfops.c | 6 +++++- client/src/cmdhftexkom.c | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/armsrc/hfops.c b/armsrc/hfops.c index ab7e5c9c4..a48b8eebd 100644 --- a/armsrc/hfops.c +++ b/armsrc/hfops.c @@ -224,6 +224,7 @@ int HfSimulateTkm(uint8_t *uid, uint8_t modulation, uint32_t timeout) { bool exit_loop = false; bool field_on = false; + uint32_t startTime = GetTickCount(); while (exit_loop == false) { button_pressed = BUTTON_PRESS(); @@ -233,6 +234,9 @@ int HfSimulateTkm(uint8_t *uid, uint8_t modulation, uint32_t timeout) { WDT_HIT(); + if (startTime > 0 && startTime + timeout < GetTickCount()) + break; + // in mV int vHf = (MAX_ADC_HF_VOLTAGE * SumAdc(ADC_CHAN_HF, 32)) >> 15; if (vHf > MF_MINFIELDV) { @@ -261,7 +265,7 @@ int HfSimulateTkm(uint8_t *uid, uint8_t modulation, uint32_t timeout) { switch_off(); if (button_pressed) - DbpString("button pressed"); + DbpString("Exit by press button"); reply_ng(CMD_HF_TEXKOM_SIMULATE, PM3_SUCCESS, NULL, 0); diff --git a/client/src/cmdhftexkom.c b/client/src/cmdhftexkom.c index 41bf1efe3..21bc87886 100644 --- a/client/src/cmdhftexkom.c +++ b/client/src/cmdhftexkom.c @@ -627,6 +627,7 @@ static int CmdHFTexkomSim(const char *Cmd) { SendCommandNG(CMD_HF_TEXKOM_SIMULATE, (uint8_t*)&payload, sizeof(payload)); if (payload.timeout > 0 && payload.timeout < 2800) { + PrintAndLogEx(INFO, "simulate command started"); PacketResponseNG resp; if (WaitForResponseTimeout(CMD_HF_TEXKOM_SIMULATE, &resp, 3000) == false) { if (verbose) { @@ -636,7 +637,7 @@ static int CmdHFTexkomSim(const char *Cmd) { } PrintAndLogEx(INFO, "simulate command execution done"); } else { - PrintAndLogEx(INFO, "simulate command started"); + PrintAndLogEx(INFO, "simulate command started..."); } return PM3_SUCCESS;