From bcbe76064d874a5d616f36709b453acd1edafcf1 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 1 Dec 2023 10:58:33 +0100 Subject: [PATCH] Changed modulation max bit length from 512 to 4096, since we now can get much longer traces --- client/src/cmddata.c | 8 ++++---- common/lfdemod.c | 10 +++++----- common/lfdemod.h | 3 +++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 47c8ef910..62b824304 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -222,7 +222,7 @@ static int CmdSetDebugMode(const char *Cmd) { return PM3_SUCCESS; } -// max output to 512 bits if we have more +// max output to MAX_DEMODULATION_BITS bits if we have more // doesn't take inconsideration where the demod offset or bitlen found. int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_hex) { size_t len = g_DemodBufferLen; @@ -257,8 +257,8 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h len = (g_DemodBufferLen - offset); } - if (len > 512) { - len = 512; + if (len > MAX_DEMODULATION_BITS) { + len = MAX_DEMODULATION_BITS; } if (invert) { @@ -275,7 +275,7 @@ int printDemodBuff(uint8_t offset, bool strip_leading, bool invert, bool print_h if (print_hex) { p = (buf + offset); - char hex[512] = {0x00}; + char hex[MAX_DEMODULATION_BITS + 1] = {0x00}; int num_bits = binarraytohex(hex, sizeof(hex), (char *)p, len); if (num_bits == 0) { p = NULL; diff --git a/common/lfdemod.c b/common/lfdemod.c index 9ed6f4e28..1255396c9 100644 --- a/common/lfdemod.c +++ b/common/lfdemod.c @@ -53,8 +53,8 @@ // ********************************************************************************************** // ---------------------------------Utilities Section-------------------------------------------- // ********************************************************************************************** -#define LOWEST_DEFAULT_CLOCK 32 -#define FSK_PSK_THRESHOLD 123 +#define LOWEST_DEFAULT_CLOCK 32 +#define FSK_PSK_THRESHOLD 123 //to allow debug print calls when used not on dev @@ -1496,7 +1496,7 @@ bool DetectST(uint8_t *buffer, size_t *size, int *foundclock, size_t *ststart, s static int millerRawDecode(uint8_t *bits, size_t *size, int invert) { if (*size < 16) return -1; - uint16_t MaxBits = 512, errCnt = 0; + uint16_t MaxBits = MAX_DEMODULATION_BITS, errCnt = 0; size_t i, bitCnt = 0; uint8_t alignCnt = 0, curBit = bits[0], alignedIdx = 0, halfClkErr = 0; @@ -1540,7 +1540,7 @@ int BiphaseRawDecode(uint8_t *bits, size_t *size, int *offset, int invert) { uint16_t bitnum = 0; uint16_t errCnt = 0; size_t i = *offset; - uint16_t maxbits = 512; + uint16_t maxbits = MAX_DEMODULATION_BITS; //check for phase change faults - skip one sample if faulty bool offsetA = true, offsetB = true; @@ -1580,7 +1580,7 @@ uint16_t manrawdecode(uint8_t *bits, size_t *size, uint8_t invert, uint8_t *alig if (*size < 16) return 0xFFFF; int errCnt = 0, bestErr = 1000; - uint16_t bitnum = 0, maxBits = 512, bestRun = 0; + uint16_t bitnum = 0, maxBits = MAX_DEMODULATION_BITS, bestRun = 0; size_t i; //find correct start position [alignment] diff --git a/common/lfdemod.h b/common/lfdemod.h index c8ca0cfea..a33752b31 100644 --- a/common/lfdemod.h +++ b/common/lfdemod.h @@ -30,6 +30,9 @@ // ignore first x samples of the buffer #define SIGNAL_IGNORE_FIRST_SAMPLES 10 +// Max number of bits when demodulating a signal +#define MAX_DEMODULATION_BITS 4096 + // generic typedef struct { int low;