From 38cb7c71c52b1b710dd0a8a8883713617b713035 Mon Sep 17 00:00:00 2001 From: marshmellow42 Date: Wed, 1 Feb 2017 15:39:10 -0500 Subject: [PATCH] add check for no wave in graphbuffer prior to... hitag lf search check --- client/cmdlf.c | 12 ++++++++---- client/graph.c | 10 ++++++++++ client/graph.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/client/cmdlf.c b/client/cmdlf.c index 2000f6d0..59f6cd0d 100644 --- a/client/cmdlf.c +++ b/client/cmdlf.c @@ -1180,10 +1180,14 @@ int CmdLFfind(const char *Cmd) return 1; } - if (!offline && (cmdp != '1')){ - ans=CmdLFHitagReader("26"); - if (ans==0) { - return 1; + size_t testLen = (GraphTraceLen < 500) ? GraphTraceLen : 500; + // only run if graphbuffer is just noise as it should be for hitag + if (graphJustNoise(GraphBuffer, testLen)) { + if (!offline && (cmdp != '1')){ + ans=CmdLFHitagReader("26"); + if (ans==0) { + return 1; + } } } diff --git a/client/graph.c b/client/graph.c index 319cde39..ab10a446 100644 --- a/client/graph.c +++ b/client/graph.c @@ -268,3 +268,13 @@ uint8_t fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, bool verbose) } return 1; } +bool graphJustNoise(int *BitStream, int size) +{ + static const uint8_t THRESHOLD = 10; //might not be high enough for noisy environments + //test samples are not just noise + bool justNoise1 = 1; + for(int idx=0; idx < size && justNoise1 ;idx++){ + justNoise1 = BitStream[idx] < THRESHOLD; + } + return justNoise1; +} diff --git a/client/graph.h b/client/graph.h index 8deeb386..6f3f600d 100644 --- a/client/graph.h +++ b/client/graph.h @@ -22,6 +22,7 @@ uint8_t GetPskCarrier(const char str[], bool printAns, bool verbose); uint8_t GetNrzClock(const char str[], bool printAns, bool verbose); uint8_t GetFskClock(const char str[], bool printAns, bool verbose); uint8_t fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, bool verbose); +bool graphJustNoise(int *BitStream, int size); void setGraphBuf(uint8_t *buff, size_t size); void save_restoreGB(uint8_t saveOpt); -- 2.39.5