]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
fix occasional strange printed clock value with...
authormarshmellow42 <marshmellowrf@gmail.com>
Mon, 14 Dec 2015 21:51:11 +0000 (16:51 -0500)
committermarshmellow42 <marshmellowrf@gmail.com>
Mon, 14 Dec 2015 21:51:11 +0000 (16:51 -0500)
...fskdemod
Fix Q5 tag detection in lf t55xx detect
Fix param_get8 reversed parameters

client/cmddata.c
client/cmdlft55xx.c
client/util.c

index e8b77d1ddedfd578e565e610b60220990ec68a03..05c495d977969d0e647a588c168ad5f673f1e027 100644 (file)
@@ -944,35 +944,32 @@ int FSKrawDemod(const char *Cmd, bool verbose)
 {
        //raw fsk demod  no manchester decoding no start bit finding just get binary from wave
        uint8_t rfLen, invert, fchigh, fclow;
 {
        //raw fsk demod  no manchester decoding no start bit finding just get binary from wave
        uint8_t rfLen, invert, fchigh, fclow;
-
        //set defaults
        //set options from parameters entered with the command
        //set defaults
        //set options from parameters entered with the command
-       rfLen = param_get8ex(Cmd, 0, 0, 10);
-       invert = param_get8ex(Cmd, 1, 0, 10);
-       fchigh = param_get8ex(Cmd, 2, 0, 10);
-       fclow = param_get8ex(Cmd, 3, 0, 10);
-
+       rfLen = param_get8(Cmd, 0);
+       invert = param_get8(Cmd, 1);
+       fchigh = param_get8(Cmd, 2);
+       fclow = param_get8(Cmd, 3);
        if (strlen(Cmd)>0 && strlen(Cmd)<=2) {
                 if (rfLen==1){
                        invert = 1;   //if invert option only is used
                        rfLen = 0;
                 }
        }
        if (strlen(Cmd)>0 && strlen(Cmd)<=2) {
                 if (rfLen==1){
                        invert = 1;   //if invert option only is used
                        rfLen = 0;
                 }
        }
-
        uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
        size_t BitLen = getFromGraphBuf(BitStream);
        if (BitLen==0) return 0;
        //get field clock lengths
        uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
        size_t BitLen = getFromGraphBuf(BitStream);
        if (BitLen==0) return 0;
        //get field clock lengths
-       uint16_t fcs=0;
+       uint8_t fc1=0, fc2=0, rf1=0;
        if (!fchigh || !fclow) {
        if (!fchigh || !fclow) {
-               fcs = countFC(BitStream, BitLen, 1);
-               if (!fcs) {
-                       fchigh = 10;
-                       fclow = 8;
-               } else {
-                       fchigh = (fcs >> 8) & 0x00FF;
-                       fclow = fcs & 0x00FF;
+               uint8_t ans = fskClocks(&fc1, &fc2, &rf1, false);
+               if (ans == 0) {
+                       if (g_debugMode) PrintAndLog("\nError: cannot detect valid fsk field clocks");                  
+                       return 0; // can't detect field clock
                }
                }
+               fchigh = fc1;
+               fclow = fc2;
+               if (rfLen == 0) rfLen = rf1;
        }
        //get bit clock length
        if (!rfLen){
        }
        //get bit clock length
        if (!rfLen){
@@ -985,7 +982,7 @@ int FSKrawDemod(const char *Cmd, bool verbose)
 
                // Now output the bitstream to the scrollback by line of 16 bits
                if (verbose || g_debugMode) {
 
                // Now output the bitstream to the scrollback by line of 16 bits
                if (verbose || g_debugMode) {
-                       PrintAndLog("\nUsing Clock:%u, invert:%u, fchigh:%u, fclow:%u", rfLen, invert, fchigh, fclow);
+                       PrintAndLog("\nUsing Clock:%d, invert:%d, fchigh:%d, fclow:%d", rfLen, invert, fchigh, fclow);
                        PrintAndLog("%s decoded bitstream:",GetFSKType(fchigh,fclow,invert));
                        printDemodBuff();
                }
                        PrintAndLog("%s decoded bitstream:",GetFSKType(fchigh,fclow,invert));
                        printDemodBuff();
                }
index 868126c900fd65a84d7c7a269744e0c1097cee12..8b23c175f3059920cc797788da13e594f33262b4 100644 (file)
@@ -469,7 +469,7 @@ bool tryDetectModulation(){
 \r
        if (GetFskClock("", FALSE, FALSE)){ \r
                fskClocks(&fc1, &fc2, &clk, FALSE);\r
 \r
        if (GetFskClock("", FALSE, FALSE)){ \r
                fskClocks(&fc1, &fc2, &clk, FALSE);\r
-               if ( FSKrawDemod("0 0", FALSE) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)){\r
+               if ( FSKrawDemod("0 0", FALSE) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
                        tests[hits].modulation = DEMOD_FSK;\r
                        if (fc1==8 && fc2 == 5)\r
                                tests[hits].modulation = DEMOD_FSK1a;\r
                        tests[hits].modulation = DEMOD_FSK;\r
                        if (fc1==8 && fc2 == 5)\r
                                tests[hits].modulation = DEMOD_FSK1a;\r
@@ -486,7 +486,6 @@ bool tryDetectModulation(){
                                tests[hits].modulation = DEMOD_FSK1;\r
                        else if (fc1 == 10 && fc2 == 8)\r
                                tests[hits].modulation = DEMOD_FSK2a;\r
                                tests[hits].modulation = DEMOD_FSK1;\r
                        else if (fc1 == 10 && fc2 == 8)\r
                                tests[hits].modulation = DEMOD_FSK2a;\r
-\r
                        tests[hits].bitrate = bitRate;\r
                        tests[hits].inverted = TRUE;\r
                        tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
                        tests[hits].bitrate = bitRate;\r
                        tests[hits].inverted = TRUE;\r
                        tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
@@ -597,6 +596,7 @@ bool tryDetectModulation(){
                config.inverted = tests[0].inverted;\r
                config.offset = tests[0].offset;\r
                config.block0 = tests[0].block0;\r
                config.inverted = tests[0].inverted;\r
                config.offset = tests[0].offset;\r
                config.block0 = tests[0].block0;\r
+               config.Q5 = tests[0].Q5;\r
                printConfiguration( config );\r
                return TRUE;\r
        }\r
                printConfiguration( config );\r
                return TRUE;\r
        }\r
@@ -683,12 +683,12 @@ bool testQ5(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t       clk){
                uint8_t safer     = PackBits(si, 4, DemodBuffer); si += 4;     //master key\r
                uint8_t resv      = PackBits(si, 8, DemodBuffer); si += 8;\r
                // 2nibble must be zeroed.\r
                uint8_t safer     = PackBits(si, 4, DemodBuffer); si += 4;     //master key\r
                uint8_t resv      = PackBits(si, 8, DemodBuffer); si += 8;\r
                // 2nibble must be zeroed.\r
-               if (safer != 0x6) continue;\r
+               if (safer != 0x6 && safer != 0x9) continue;\r
                if ( resv > 0x00) continue;\r
                //uint8_t       pageSel   = PackBits(si, 1, DemodBuffer); si += 1;\r
                //uint8_t fastWrite = PackBits(si, 1, DemodBuffer); si += 1;\r
                si += 1+1;\r
                if ( resv > 0x00) continue;\r
                //uint8_t       pageSel   = PackBits(si, 1, DemodBuffer); si += 1;\r
                //uint8_t fastWrite = PackBits(si, 1, DemodBuffer); si += 1;\r
                si += 1+1;\r
-               int bitRate       = PackBits(si, 5, DemodBuffer)*2 + 2; si += 5;     //bit rate\r
+               int bitRate       = PackBits(si, 6, DemodBuffer)*2 + 2; si += 6;     //bit rate\r
                if (bitRate > 128 || bitRate < 8) continue;\r
 \r
                //uint8_t AOR       = PackBits(si, 1, DemodBuffer); si += 1;   \r
                if (bitRate > 128 || bitRate < 8) continue;\r
 \r
                //uint8_t AOR       = PackBits(si, 1, DemodBuffer); si += 1;   \r
index e8b72e81aeebe46884507d868bc3955fa81a2a75..32c06e910a31480c2443fb1edfaa70f9b33a35fb 100644 (file)
@@ -142,7 +142,7 @@ char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t brea
        for (size_t out_index=0; out_index < max_len; out_index++) {
                // set character
                sprintf(tmp++, "%u", data[in_index]);
        for (size_t out_index=0; out_index < max_len; out_index++) {
                // set character
                sprintf(tmp++, "%u", data[in_index]);
-               // check if a line break is needed
+               // check if a line break is needed and we have room to print it in our array
                if ( (breaks > 0) && !((in_index+1) % breaks) && (out_index+1 != max_len) ) {
                        // increment and print line break
                        out_index++;
                if ( (breaks > 0) && !((in_index+1) % breaks) && (out_index+1 != max_len) ) {
                        // increment and print line break
                        out_index++;
@@ -271,7 +271,7 @@ char param_getchar(const char *line, int paramnum)
 
 uint8_t param_get8(const char *line, int paramnum)
 {
 
 uint8_t param_get8(const char *line, int paramnum)
 {
-       return param_get8ex(line, paramnum, 10, 0);
+       return param_get8ex(line, paramnum, 0, 10);
 }
 
 /**
 }
 
 /**
Impressum, Datenschutz