]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmddata.c
CHG: Moved a 'include' statement to header file
[proxmark3-svn] / client / cmddata.c
index 6992c6d92b44f0d63a264a9f4a21f704f8a97c51..18edd33e88ba8a43be3482db3b8c39ee120f0a7a 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;
@@ -527,7 +527,11 @@ int ASKbiphaseDemod(const char *Cmd, bool verbose)
        sscanf(Cmd, "%i %i %i %i", &offset, &clk, &invert, &maxErr);
        
        uint8_t BitStream[MAX_DEMOD_BUF_LEN];
-       size_t size = getFromGraphBuf(BitStream);         
+       size_t size = getFromGraphBuf(BitStream);       
+       if (size == 0 ) {
+               if (g_debugMode) PrintAndLog("DEBUG: no data in graphbuf");  
+                       return 0;  
+       }
        //invert here inverts the ask raw demoded bits which has no effect on the demod, but we need the pointer
        int errCnt = askdemod(BitStream, &size, &clk, &invert, maxErr, 0, 0);  
        if ( errCnt < 0 || errCnt > maxErr ) {   
@@ -877,13 +881,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,9 +1322,9 @@ int CmdFSKdemodAWID(const char *Cmd)
        // bbbbbbbb w ffffffff cccccccccccccccc w xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        // |26 bit|   |-117--| |-----142------|
     //
-       // 00110010 0 0000011111010000000000000001000100101000100001111 0 00000000 
-       // bbbbbbbb w ffffffffffffffffccccccccccccccccccccccccccccccccc w xxxxxxxx
-       // |50 bit|   |----4000------||-----------2248975-------------| 
+       // 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
@@ -1332,25 +1339,25 @@ int CmdFSKdemodAWID(const char *Cmd)
                        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);
+                       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: %d - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, code2, rawHi2, rawHi, rawLo);
+                       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- (%d) - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, code2, rawHi2, rawHi, rawLo);
+                               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- (%d) - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, rawHi2, rawHi, rawLo);
+                               PrintAndLog("AWID Found - BitLength: %d -unknown BitLength- (%u) - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, rawHi2, rawHi, rawLo);
                        }
                        break;          
        }
Impressum, Datenschutz