]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmddata.c
CHG: trying to figure out why I can't get the seconds out..
[proxmark3-svn] / client / cmddata.c
index 902a63633cf661a9ce5b4512a6f0e3c5600b2726..6570b24370d2796ef71f63ff05791adc81a8c371 100644 (file)
@@ -76,7 +76,7 @@ void printDemodBuff(void)
        }
        if (bitLen>512) bitLen=512; //max output to 512 bits if we have more - should be plenty
 
-       char *bin = sprint_bin_break(DemodBuffer,bitLen,16);
+       char *bin = sprint_bin_break(DemodBuffer, bitLen,16);
        PrintAndLog("%s",bin);
 
        return;
@@ -660,7 +660,7 @@ int CmdVikingDemod(const char *Cmd)
        //call lfdemod.c demod for Viking
        int ans = VikingDemod_AM(DemodBuffer, &size);
        if (ans < 0) {
-               if (g_debugMode) PrintAndLog("Error Viking_Demod %d", ans);
+               if (g_debugMode) PrintAndLog("Error Viking_Demod %d %s", ans, (ans == -5)?"[chksum error]":"");
                return 0;
        }
        //got a good demod
@@ -756,8 +756,7 @@ int usage_data_autocorr(void)
 int CmdAutoCorr(const char *Cmd)
 {
        char cmdp = param_getchar(Cmd, 0);
-       if (cmdp == 'h' || cmdp == 'H') 
-               return usage_data_autocorr();
+       if (cmdp == 'h' || cmdp == 'H') return usage_data_autocorr();
        int window = 4000; //set default
        char grph=0;
        bool updateGrph = FALSE;
@@ -878,13 +877,16 @@ int CmdGraphShiftZero(const char *Cmd)
 int CmdAskEdgeDetect(const char *Cmd)
 {
        int thresLen = 25;
+       int last = 0;
        sscanf(Cmd, "%i", &thresLen); 
 
-       for(int i = 1; i<GraphTraceLen; i++){
-               if (GraphBuffer[i]-GraphBuffer[i-1]>=thresLen) //large jump up
-                       GraphBuffer[i-1] = 127;
-               else if(GraphBuffer[i]-GraphBuffer[i-1]<=-1*thresLen) //large jump down
-                       GraphBuffer[i-1] = -127;
+       for(int i = 1; i < GraphTraceLen; ++i){
+               if (GraphBuffer[i] - GraphBuffer[i-1] >= thresLen) //large jump up
+                       last = 127;
+               else if(GraphBuffer[i] - GraphBuffer[i-1] <= -1 * thresLen) //large jump down
+                       last = -127;
+                       
+               GraphBuffer[i-1] = last;
        }
        RepaintGraphWindow();
        return 0;
@@ -1315,37 +1317,51 @@ int CmdFSKdemodAWID(const char *Cmd)
        // 00011010 1 01110101 0000000010001110 1 000000000000000000000000000000000
        // bbbbbbbb w ffffffff cccccccccccccccc w xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        // |26 bit|   |-117--| |-----142------|
+    //
+       // 00110010 0 0000111110100000 00000000000100010010100010000111 1 000000000 
+       // bbbbbbbb w ffffffffffffffff cccccccccccccccccccccccccccccccc w xxxxxxxxx
+       // |50 bit|   |----4000------| |-----------2248975------------| 
        // b = format bit len, o = odd parity of last 3 bits
        // f = facility code, c = card number
        // w = wiegand parity
-       // (26 bit format shown)
 
        uint32_t fc = 0;
        uint32_t cardnum = 0;
        uint32_t code1 = 0;
        uint32_t code2 = 0;
-       uint8_t fmtLen = bytebits_to_byte(BitStream,8);
-       if (fmtLen==26){
-               fc = bytebits_to_byte(BitStream+9, 8);
-               cardnum = bytebits_to_byte(BitStream+17, 16);
-               code1 = bytebits_to_byte(BitStream+8,fmtLen);
-               PrintAndLog("AWID Found - BitLength: %d, FC: %d, Card: %d - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, rawHi2, rawHi, rawLo);
-       } else {
-               cardnum = bytebits_to_byte(BitStream+8+(fmtLen-17), 16);
-               if (fmtLen>32){
-                       code1 = bytebits_to_byte(BitStream+8,fmtLen-32);
-                       code2 = bytebits_to_byte(BitStream+8+(fmtLen-32),32);
-                       PrintAndLog("AWID Found - BitLength: %d -unknown BitLength- (%d) - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, code2, rawHi2, rawHi, rawLo);
-               } else{
-                       code1 = bytebits_to_byte(BitStream+8,fmtLen);
-                       PrintAndLog("AWID Found - BitLength: %d -unknown BitLength- (%d) - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, rawHi2, rawHi, rawLo);
-               }
+       uint8_t fmtLen = bytebits_to_byte(BitStream, 8);
+       switch(fmtLen) {
+               case 26: 
+                       fc = bytebits_to_byte(BitStream + 9, 8);
+                       cardnum = bytebits_to_byte(BitStream + 17, 16);
+                       code1 = bytebits_to_byte(BitStream + 8,fmtLen);
+                       PrintAndLog("AWID Found - BitLength: %d, FC: %d, Card: %u - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, rawHi2, rawHi, rawLo);
+                       break;
+               case 50:
+                       fc = bytebits_to_byte(BitStream + 9, 16);
+                       cardnum = bytebits_to_byte(BitStream + 25, 32);
+                       code1 = bytebits_to_byte(BitStream + 8, (fmtLen-32) );
+                       code2 = bytebits_to_byte(BitStream + 8 + (fmtLen-32), 32);
+                       PrintAndLog("AWID Found - BitLength: %d, FC: %d, Card: %u - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, code2, rawHi2, rawHi, rawLo);
+                       break;
+               default:
+                       if (fmtLen > 32 ) {
+                               cardnum = bytebits_to_byte(BitStream+8+(fmtLen-17), 16);
+                               code1 = bytebits_to_byte(BitStream+8,fmtLen-32);
+                               code2 = bytebits_to_byte(BitStream+8+(fmtLen-32),32);
+                               PrintAndLog("AWID Found - BitLength: %d -unknown BitLength- (%u) - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, code2, rawHi2, rawHi, rawLo);
+                       } else {
+                               cardnum = bytebits_to_byte(BitStream+8+(fmtLen-17), 16);
+                               code1 = bytebits_to_byte(BitStream+8,fmtLen);
+                               PrintAndLog("AWID Found - BitLength: %d -unknown BitLength- (%u) - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, rawHi2, rawHi, rawLo);
+                       }
+                       break;          
        }
+
        if (g_debugMode){
                PrintAndLog("DEBUG: idx: %d, Len: %d Printing Demod Buffer:", idx, 96);
                printDemodBuff();
        }
-       //todo - convert hi2, hi, lo to demodbuffer for future sim/clone commands
        return 1;
 }
 
@@ -2363,6 +2379,12 @@ int Cmdhex2bin(const char *Cmd)
        return 0;
 }
 
+int CmdDataIIR(const char *Cmd){
+       iceIIR_Butterworth(GraphBuffer, GraphTraceLen);
+       RepaintGraphWindow();
+       return 0;
+}
+
 static command_t CommandTable[] =
 {
        {"help",            CmdHelp,            1, "This help"},
@@ -2409,6 +2431,7 @@ static command_t CommandTable[] =
        {"tune",            CmdTuneSamples,     0, "Get hw tune samples for graph window"},
        {"undec",           CmdUndec,           1, "Un-decimate samples by 2"},
        {"zerocrossings",   CmdZerocrossings,   1, "Count time between zero-crossings"},
+       {"iir",                         CmdDataIIR,                     0, "apply IIR buttersworth filter on plotdata"},
        {NULL, NULL, 0, NULL}
 };
 
Impressum, Datenschutz