]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdlft55xx.c
prepare to update the LF T55XX commands
[proxmark3-svn] / client / cmdlft55xx.c
index f35edaa4669fe23e9c2257bbb145ebf79fa7929a..c023d57f6a06467bc9ba16e47f303eeda00994b8 100644 (file)
@@ -65,8 +65,12 @@ int CmdReadBlk(const char *Cmd)
        int invert = 0;\r
        int clk = 0;\r
        int block = -1;\r
+       int errCnt;\r
+       size_t bitlen;\r
+       //int decodedBitlen;\r
+       uint32_t blockData;\r
        uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0x00};\r
-\r
+       \r
        sscanf(Cmd, "%d", &block);\r
        \r
        if ((block > 7) | (block < 0)) {\r
@@ -78,21 +82,21 @@ int CmdReadBlk(const char *Cmd)
        SendCommand(&c);\r
        if ( !WaitForResponseTimeout(CMD_ACK,NULL,1500) ) {\r
                PrintAndLog("command execution time out");\r
-               return 1;\r
+               return 2;\r
        }\r
        \r
-       CmdSamples("");\r
+       CmdSamples("12000");\r
 \r
-       size_t bitlen = getFromGraphBuf(bits);\r
+       bitlen = getFromGraphBuf(bits);\r
        \r
-       int errCnt = askrawdemod(bits, &bitlen, &clk, &invert);\r
+       errCnt = askrawdemod(bits, &bitlen, &clk, &invert);\r
        \r
        //throw away static - allow 1 and -1 (in case of threshold command first)\r
        if ( errCnt == -1 || bitlen < 16 ){  \r
                PrintAndLog("no data found");\r
                if (g_debugMode) \r
                        PrintAndLog("errCnt: %d, bitlen: %d, clk: %d, invert: %d", errCnt, bitlen, clk, invert);\r
-               return 0;\r
+               return 3;\r
        }\r
        if (g_debugMode) \r
                PrintAndLog("Using Clock: %d - invert: %d - Bits Found: %d", clk, invert, bitlen);\r
@@ -100,6 +104,23 @@ int CmdReadBlk(const char *Cmd)
        //move bits back to DemodBuffer\r
        setDemodBuf(bits, bitlen, 0);\r
        printBitStream(bits,bitlen);\r
+       \r
+       // bits has the manchester encoded data.\r
+       errCnt = manrawdecode(bits, &bitlen);   \r
+       if ( errCnt == -1 || bitlen < 16 ){  \r
+               PrintAndLog("no data found");\r
+               if (g_debugMode) \r
+                       PrintAndLog("errCnt: %d, bitlen: %d, clk: %d, invert: %d", errCnt, bitlen, clk, invert);\r
+               return 4;\r
+       }\r
+\r
+       blockData = PackBits(0, 32, bits);\r
+\r
+       if ( block < 0)\r
+               PrintAndLog(" Decoded     : 0x%08X  %s", blockData, sprint_bin(bits,32) );\r
+       else\r
+               PrintAndLog(" Block %d    : 0x%08X  %s", block, blockData, sprint_bin(bits,32) );\r
+       \r
        return 0;\r
 }\r
 \r
@@ -391,9 +412,7 @@ int ManchesterDemod(int blockNum){
        uint8_t  bits[LF_BITSSTREAM_LEN] = {0x00};\r
        uint8_t * bitstream = bits;\r
        \r
-       //manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream, LF_BITSSTREAM_LEN);     \r
        manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bits, LF_BITSSTREAM_LEN);    \r
-    //blockData = PackBits(offset, sizebyte, bitstream);\r
        blockData = PackBits(offset, sizebyte, bits);\r
 \r
        if ( blockNum < 0)\r
@@ -524,7 +543,7 @@ static command_t CommandTable[] =
   {"trace",  CmdReadTrace,   0, "[1] Read T55xx traceability data (page 1/ blk 0-1)"},\r
   {"info",   CmdInfo,        0, "[1] Read T55xx configuration data (page 0/ blk 0)"},\r
   {"dump",   CmdDump,        0, "[password] Dump T55xx card block 0-7. optional with password"},\r
-  {"fsk",    CmdIceFsk,      0, "FSK demod"},\r
+  //{"fsk",    CmdIceFsk,      0, "FSK demod"},\r
   {"man",    CmdIceManchester,      0, "Manchester demod (with SST)"},\r
   {NULL, NULL, 0, NULL}\r
 };\r
Impressum, Datenschutz