]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
CHG: enhanced the debug output for some LF demod/decode
authoriceman1001 <iceman@iuse.se>
Fri, 16 Dec 2016 11:04:37 +0000 (12:04 +0100)
committericeman1001 <iceman@iuse.se>
Fri, 16 Dec 2016 11:04:37 +0000 (12:04 +0100)
client/cmddata.c
common/lfdemod.c

index 08ff7aa8d9156dbec3594ed2fc45387e33e2bb8b..bbe857d3b6ed3064377bd746903c26a2f3c023ed 100644 (file)
@@ -1512,17 +1512,17 @@ int CmdFSKdemodPyramid(const char *Cmd)
        if (idx < 0){
                if (g_debugMode){
                        if (idx == -5)
-                               PrintAndLog("DEBUG: Error - not enough samples");
+                               PrintAndLog("DEBUG: Error - Pyramid: not enough samples");
                        else if (idx == -1)
-                               PrintAndLog("DEBUG: Error - only noise found");
+                               PrintAndLog("DEBUG: Error - Pyramid: only noise found");
                        else if (idx == -2)
-                               PrintAndLog("DEBUG: Error - problem during FSK demod");
+                               PrintAndLog("DEBUG: Error - Pyramid: problem during FSK demod");
                        else if (idx == -3)
-                               PrintAndLog("DEBUG: Error - Size not correct: %d", size);
+                               PrintAndLog("DEBUG: Error - Pyramid: size not correct: %d", size);
                        else if (idx == -4)
-                               PrintAndLog("DEBUG: Error - Pyramid preamble not found");
+                               PrintAndLog("DEBUG: Error - Pyramid: preamble not found");
                        else
-                               PrintAndLog("DEBUG: Error - idx: %d",idx);
+                               PrintAndLog("DEBUG: Error - Pyramid: idx: %d",idx);
                }
                return 0;
        }
@@ -1555,19 +1555,23 @@ int CmdFSKdemodPyramid(const char *Cmd)
        }
        //check checksum calc
        //checksum calc thanks to ICEMAN!!
-       uint32_t checkCS =  CRC8Maxim(csBuff,13);
+       uint32_t checkCS =  CRC8Maxim(csBuff, 13);
 
        //get raw ID before removing parities
-       uint32_t rawLo = bytebits_to_byte(BitStream+idx+96,32);
-       uint32_t rawHi = bytebits_to_byte(BitStream+idx+64,32);
-       uint32_t rawHi2 = bytebits_to_byte(BitStream+idx+32,32);
-       uint32_t rawHi3 = bytebits_to_byte(BitStream+idx,32);
-       setDemodBuf(BitStream,128,idx);
+       uint32_t rawLo = bytebits_to_byte(BitStream+idx+96, 32);
+       uint32_t rawHi = bytebits_to_byte(BitStream+idx+64, 32);
+       uint32_t rawHi2 = bytebits_to_byte(BitStream+idx+32, 32);
+       uint32_t rawHi3 = bytebits_to_byte(BitStream+idx, 32);
+       setDemodBuf(BitStream, 128, idx);
 
        size = removeParity(BitStream, idx+8, 8, 1, 120);
        if (size != 105){
-               if (g_debugMode) 
-                       PrintAndLog("DEBUG: Error at parity check - tag size does not match Pyramid format, SIZE: %d, IDX: %d, hi3: %x",size, idx, rawHi3);
+               if (g_debugMode) {
+                       if ( size == 0)
+                               PrintAndLog("DEBUG: Error - Pyramid: parity check failed - IDX: %d, hi3: %08X", idx, rawHi3);
+                       else
+                               PrintAndLog("DEBUG: Error - Pyramid: at parity check - tag size does not match Pyramid format, SIZE: %d, IDX: %d, hi3: %08X", size, idx, rawHi3);
+               }
                return 0;
        }
 
@@ -1625,7 +1629,7 @@ int CmdFSKdemodPyramid(const char *Cmd)
                PrintAndLog("Checksum %02x failed - should have been %02x", checksum, checkCS);
 
        if (g_debugMode){
-               PrintAndLog("DEBUG: idx: %d, Len: %d, Printing Demod Buffer:", idx, 128);
+               PrintAndLog("DEBUG: Pyramid: idx: %d, Len: %d, Printing Demod Buffer:", idx, 128);
                printDemodBuff();
        }
        return 1;
index aa3586f6cedd4a0af3677f1f9d4c5e90edcd2605..64e6775c580ca436c2bf88fb3c1cd655e97bd9e2 100644 (file)
@@ -71,7 +71,7 @@ size_t removeParity(uint8_t *BitStream, size_t startIdx, uint8_t pLen, uint8_t p
 {
        uint32_t parityWd = 0;
        size_t j = 0, bitCnt = 0;
-       for (int word = 0; word < (bLen); word+=pLen){
+       for (int word = 0; word < (bLen); word += pLen){
                for (int bit=0; bit < pLen; bit++){
                        parityWd = (parityWd << 1) | BitStream[startIdx+word+bit];
                        BitStream[j++] = (BitStream[startIdx+word+bit]);
@@ -83,7 +83,7 @@ size_t removeParity(uint8_t *BitStream, size_t startIdx, uint8_t pLen, uint8_t p
                        case 2:  if (BitStream[j]==0) { return 0; } break; //should be 1 spacer bit
                        default: if (parityTest(parityWd, pLen, pType) == 0) { return 0; } break; //test parity
                }
-               bitCnt+=(pLen-1);
+               bitCnt += (pLen-1);
                parityWd = 0;
        }
        // if we got here then all the parities passed
@@ -815,7 +815,7 @@ int PyramiddemodFSK(uint8_t *dest, size_t *size)
        *size = fskdemod(dest, *size, 50, 1, 10, 8);  // fsk2a RF/50 
        if (*size < 128) return -2;  //did we get a good demod?
 
-       uint8_t preamble[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
+       uint8_t preamble[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1};
        size_t startIdx = 0;
        uint8_t errChk = preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx);
        if (errChk == 0) return -4; //preamble not found
Impressum, Datenschutz