]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - common/lfdemod.c
CHG: `lf em` - some minor refactoring in 4x50 commands
[proxmark3-svn] / common / lfdemod.c
index 49c5877e0d36c45a0fb7c026c9cf341f44a27906..552411434717c9cd3fcbc410909f7a928a680a5b 100644 (file)
@@ -7,22 +7,20 @@
 //-----------------------------------------------------------------------------
 // Low frequency demod/decode commands
 //-----------------------------------------------------------------------------
-
-#include <stdlib.h>
 #include "lfdemod.h"
-#include <string.h>
 
 //un_comment to allow debug print calls when used not on device
 void dummy(char *fmt, ...){}
 
+
 #ifndef ON_DEVICE
-#include "ui.h"
-#include "cmdparser.h"
-#include "cmddata.h"
-#define prnt PrintAndLog
+# include "ui.h"
+# include "cmdparser.h"
+# include "cmddata.h"
+# define prnt PrintAndLog
 #else 
        uint8_t g_debugMode=0;
-#define prnt dummy
+# define prnt dummy
 #endif
 
 //test samples are not just noise
@@ -278,6 +276,7 @@ int askdemod(uint8_t *BinStream, size_t *size, int *clk, int *invert, int maxErr
 {
        if (*size==0) return -1;
        int start = DetectASKClock(BinStream, *size, clk, maxErr); //clock default
+
        if (*clk==0 || start < 0) return -3;
        if (*invert != 1) *invert = 0;
        if (amp==1) askAmp(BinStream, *size);
@@ -350,9 +349,9 @@ int askdemod(uint8_t *BinStream, size_t *size, int *clk, int *invert, int maxErr
 //take 10 and 01 and manchester decode
 //run through 2 times and take least errCnt
 int manrawdecode(uint8_t * BitStream, size_t *size, uint8_t invert){
-       uint16_t bitnum = 0, MaxBits = 512, errCnt = 0;
+       int errCnt = 0, bestErr = 1000;
+       uint16_t bitnum = 0, MaxBits = 512, bestRun = 0;
        size_t i, k;
-       uint16_t bestErr = 1000, bestRun = 0;
        if (*size < 16) return -1;
        //find correct start position [alignment]
        for (k=0; k < 2; ++k){
Impressum, Datenschutz