fix #1175 - biphase demod identification of value clocks now fails if no changes detected

This commit is contained in:
iceman1001 2021-01-28 00:35:14 +01:00
commit 02c1034caa

View file

@ -41,6 +41,8 @@
#include <stdlib.h> // qsort #include <stdlib.h> // qsort
#include "parity.h" // for parity test #include "parity.h" // for parity test
#include "pm3_cmd.h" // error codes #include "pm3_cmd.h" // error codes
#include "commonutil.h" // Arraylen
// ********************************************************************************************** // **********************************************************************************************
// ---------------------------------Utilities Section-------------------------------------------- // ---------------------------------Utilities Section--------------------------------------------
// ********************************************************************************************** // **********************************************************************************************
@ -770,6 +772,22 @@ int DetectASKClock(uint8_t *dest, size_t size, int *clock, int maxErr) {
//if (g_debugMode == 2) prnt("DEBUG ASK: clk %d, # Errors %d, Current Best Clk %d, bestStart %d", clk[k], bestErr[k], clk[best], bestStart[best]); //if (g_debugMode == 2) prnt("DEBUG ASK: clk %d, # Errors %d, Current Best Clk %d, bestStart %d", clk[k], bestErr[k], clk[best], bestStart[best]);
} }
bool chg = false;
for (i = 0; i < ARRAYLEN(bestErr); i++) {
chg = (bestErr[i] != 1000);
if (chg)
break;
chg = (bestStart[i] != 0);
if (chg)
break;
}
// just noise - no super good detection. good enough
if (chg == false) {
if (g_debugMode == 2) prnt("DEBUG DetectASKClock: no good values detected - aborting");
return -2;
}
if (!found_clk) if (!found_clk)
*clock = clk[best]; *clock = clk[best];