]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdlft55xx.c
Merge pull request #282 from Proxmark/graphwork2
[proxmark3-svn] / client / cmdlft55xx.c
index 72345c9d2a75d708aa2ccd829050d00543795b93..252aaaa2a9440cca6812b488b5fd6c8d1ae608de 100644 (file)
@@ -141,15 +141,16 @@ int usage_t55xx_detect(){
        return 0;\r
 }\r
 int usage_t55xx_detectP1(){\r
-       PrintAndLog("Usage:  lf t55xx page1detect [1] [p <password>]");\r
+       PrintAndLog("Command: Detect Page 1 of a t55xx chip");\r
+       PrintAndLog("Usage:  lf t55xx p1detect [1] [p <password>]");\r
        PrintAndLog("Options:");\r
        PrintAndLog("     1             - if set, use Graphbuffer otherwise read data from tag.");\r
        PrintAndLog("     p <password>  - OPTIONAL password (8 hex characters)");\r
        PrintAndLog("");\r
        PrintAndLog("Examples:");\r
-       PrintAndLog("      lf t55xx page1detect");\r
-       PrintAndLog("      lf t55xx page1detect 1");\r
-       PrintAndLog("      lf t55xx page1detect p 11223344");\r
+       PrintAndLog("      lf t55xx p1detect");\r
+       PrintAndLog("      lf t55xx p1detect 1");\r
+       PrintAndLog("      lf t55xx p1detect p 11223344");\r
        PrintAndLog("");\r
        return 0;\r
 }\r
@@ -418,23 +419,23 @@ bool DecodeT55xxBlock(){
                        break;\r
                case DEMOD_PSK1:\r
                        // skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)\r
-                       save_restoreGB(1);\r
+                       save_restoreGB(GRAPH_SAVE);\r
                        CmdLtrim("160");\r
                        snprintf(cmdStr, sizeof(buf),"%d %d 6", bitRate[config.bitrate], config.inverted );\r
                        ans = PSKDemod(cmdStr, false);\r
                        //undo trim samples\r
-                       save_restoreGB(0);\r
+                       save_restoreGB(GRAPH_RESTORE);\r
                        break;\r
                case DEMOD_PSK2: //inverted won't affect this\r
                case DEMOD_PSK3: //not fully implemented\r
                        // skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)\r
-                       save_restoreGB(1);\r
+                       save_restoreGB(GRAPH_SAVE);\r
                        CmdLtrim("160");\r
                        snprintf(cmdStr, sizeof(buf),"%d 0 6", bitRate[config.bitrate] );\r
                        ans = PSKDemod(cmdStr, false);\r
                        psk1TOpsk2(DemodBuffer, DemodBufferLen);\r
                        //undo trim samples\r
-                       save_restoreGB(0);\r
+                       save_restoreGB(GRAPH_RESTORE);\r
                        break;\r
                case DEMOD_NRZ:\r
                        snprintf(cmdStr, sizeof(buf),"%d %d 1", bitRate[config.bitrate], config.inverted );\r
@@ -506,8 +507,8 @@ bool tryDetectModulation(){
        t55xx_conf_block_t tests[15];\r
        int bitRate=0;\r
        uint8_t fc1 = 0, fc2 = 0, ans = 0;\r
-       int clk=0;\r
-       ans = fskClocks(&fc1, &fc2, (uint8_t *)&clk, false);\r
+       int clk = 0, firstClockEdge = 0;\r
+       ans = fskClocks(&fc1, &fc2, (uint8_t *)&clk, false, &firstClockEdge);\r
        if (ans && ((fc1==10 && fc2==8) || (fc1==8 && fc2==5))) {\r
                if ( FSKrawDemod("0 0", false) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
                        tests[hits].modulation = DEMOD_FSK;\r
@@ -570,7 +571,7 @@ bool tryDetectModulation(){
                        }\r
                }\r
                clk = GetNrzClock("", false, false);\r
-               if (clk>0) {\r
+               if (clk>8) { //clock of rf/8 is likely a false positive, so don't use it.\r
                        if ( NRZrawDemod("0 0 1", false)  && test(DEMOD_NRZ, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
                                tests[hits].modulation = DEMOD_NRZ;\r
                                tests[hits].bitrate = bitRate;\r
@@ -593,7 +594,7 @@ bool tryDetectModulation(){
                clk = GetPskClock("", false, false);\r
                if (clk>0) {\r
                        // allow undo\r
-                       save_restoreGB(1);\r
+                       save_restoreGB(GRAPH_SAVE);\r
                        // skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)\r
                        CmdLtrim("160");\r
                        if ( PSKDemod("0 0 6", false) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
@@ -637,7 +638,7 @@ bool tryDetectModulation(){
                                }\r
                        } // inverse waves does not affect this demod\r
                        //undo trim samples\r
-                       save_restoreGB(0);\r
+                       save_restoreGB(GRAPH_RESTORE);\r
                }\r
        }       \r
        if ( hits == 1) {\r
@@ -809,6 +810,7 @@ bool test(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk, bool *Q5)
                        if (!testBitRate(bitRate, clk)) continue;\r
                } else { //extended mode bitrate = same function to calc bitrate as em4x05\r
                        if (EM4x05_GET_BITRATE(bitRate) != clk) continue;\r
+\r
                }\r
                //test modulation\r
                if (!testModulation(mode, modread)) continue;\r
@@ -868,7 +870,7 @@ int special(const char *Cmd) {
 int printConfiguration( t55xx_conf_block_t b){\r
        PrintAndLog("Chip Type  : %s", (b.Q5) ? "T5555(Q5)" : "T55x7");\r
        PrintAndLog("Modulation : %s", GetSelectedModulationStr(b.modulation) );\r
-       PrintAndLog("Bit Rate   : %s", GetBitRateStr(b.bitrate, (b.block0 & T55x7_X_MODE)) );\r
+       PrintAndLog("Bit Rate   : %s", GetBitRateStr(b.bitrate, (b.block0 & T55x7_X_MODE && (b.block0>>28==6 || b.block0>>28==9))) );\r
        PrintAndLog("Inverted   : %s", (b.inverted) ? "Yes" : "No" );\r
        PrintAndLog("Offset     : %d", b.offset);\r
        PrintAndLog("Seq. Term. : %s", (b.ST) ? "Yes" : "No" );\r
@@ -1232,11 +1234,7 @@ int AquireData( uint8_t page, uint8_t block, bool pwdmode, uint32_t password ){
                PrintAndLog("command execution time out");\r
                return 0;\r
        }\r
-\r
-       uint8_t got[12000];\r
-       GetFromBigBuf(got,sizeof(got),0);\r
-       WaitForResponse(CMD_ACK,NULL);\r
-       setGraphBuf(got, sizeof(got));\r
+       getSamples(12000,true);\r
        return 1;\r
 }\r
 \r
@@ -1557,7 +1555,7 @@ bool tryDetectP1(bool getData) {
        uint8_t preamble[] = {1,1,1,0,0,0,0,0,0,0,0,1,0,1,0,1};\r
        size_t startIdx = 0;\r
        uint8_t fc1 = 0, fc2 = 0, ans = 0;\r
-       int clk = 0;\r
+       int clk = 0, firstClockEdge = 0;\r
        bool st = true;\r
 \r
        if ( getData ) {\r
@@ -1566,7 +1564,7 @@ bool tryDetectP1(bool getData) {
        }\r
 \r
        // try fsk clock detect. if successful it cannot be any other type of modulation...  (in theory...)\r
-       ans = fskClocks(&fc1, &fc2, (uint8_t *)&clk, false);\r
+       ans = fskClocks(&fc1, &fc2, (uint8_t *)&clk, false, &firstClockEdge);\r
        if (ans && ((fc1==10 && fc2==8) || (fc1==8 && fc2==5))) {\r
                if ( FSKrawDemod("0 0", false) && \r
                          preambleSearchEx(DemodBuffer,preamble,sizeof(preamble),&DemodBufferLen,&startIdx,false) && \r
Impressum, Datenschutz