From 2613284dfce598a9e69cd559cb64cc9ef6ac5bfc Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 1 Dec 2020 17:06:49 +0100 Subject: [PATCH] fix lf search - cotag exiting on deviceside --- armsrc/lfsampling.c | 23 ++++++++++++++++++++++- client/src/cmdlf.c | 2 +- client/src/cmdlfcotag.c | 11 +++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index d31342ac0..7a42367dc 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -509,10 +509,21 @@ void doCotagAcquisition(void) { bool firsthigh = false, firstlow = false; uint16_t i = 0, noise_counter = 0; + uint16_t checker = 0; + while ((i < bufsize - 1) && (noise_counter < COTAG_T1 << 1)) { if (BUTTON_PRESS()) break; + + if (checker == 4000) { + if (data_available()) + break; + else + checker = 0; + } else { + ++checker; + } WDT_HIT(); @@ -567,12 +578,22 @@ uint16_t doCotagAcquisitionManchester(uint8_t *dest, uint16_t destlen) { bool firsthigh = false, firstlow = false; uint8_t curr = 0, prev = 0; uint16_t i = 0; - uint16_t period = 0; + uint16_t period = 0, checker = 0; while ((i < destlen) && BUTTON_PRESS() == false) { WDT_HIT(); + if (checker == 4000) { + if (data_available()) + break; + else + checker = 0; + } else { + ++checker; + } + + if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) { volatile uint8_t sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR; diff --git a/client/src/cmdlf.c b/client/src/cmdlf.c index 77dda02f1..7cd9d801e 100644 --- a/client/src/cmdlf.c +++ b/client/src/cmdlf.c @@ -1434,8 +1434,8 @@ int CmdLFfind(const char *Cmd) { return PM3_SUCCESS; } + PrintAndLogEx(INPLACE, "Searching for COTAG tag..."); if (readCOTAGUid()) { - PrintAndLogEx(INPLACE, "Searching for COTAG tag..."); PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("COTAG ID") " found!"); return PM3_SUCCESS; } diff --git a/client/src/cmdlfcotag.c b/client/src/cmdlfcotag.c index c339f677a..abe426e30 100644 --- a/client/src/cmdlfcotag.c +++ b/client/src/cmdlfcotag.c @@ -122,15 +122,23 @@ static int CmdCOTAGReader(const char *Cmd) { SendCommandNG(CMD_LF_COTAG_READ, (uint8_t *)&payload, sizeof(payload)); uint8_t timeout = 3; + int res = PM3_SUCCESS; while (!WaitForResponseTimeout(CMD_LF_COTAG_READ, &resp, 2000)) { timeout--; PrintAndLogEx(NORMAL, "." NOLF); if (timeout == 0) { + PrintAndLogEx(NORMAL, ""); PrintAndLogEx(WARNING, "command execution time out"); - return PM3_ETIMEOUT; + SendCommandNG(CMD_BREAK_LOOP, NULL, 0); + timeout = 1; + res = PM3_ETIMEOUT; } } + if (res != PM3_SUCCESS) { + return res; + } + if (timeout != 3) PrintAndLogEx(NORMAL, ""); @@ -157,7 +165,6 @@ static command_t CommandTable[] = { {"reader", CmdCOTAGReader, IfPm3Lf, "Attempt to read and extract tag data"}, {NULL, NULL, NULL, NULL} }; - static int CmdHelp(const char *Cmd) { (void)Cmd; // Cmd is not used so far CmdsHelp(CommandTable);