]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX: lf t55xx config now handles offsets.
authoriceman1001 <iceman@iuse.se>
Sun, 15 Mar 2015 20:36:38 +0000 (21:36 +0100)
committericeman1001 <iceman@iuse.se>
Sun, 15 Mar 2015 20:36:38 +0000 (21:36 +0100)
FIX: lf t55xx trace now handles offsets.
FIX: lf t55xx info now handles offsets.

client/cmdlft55xx.c

index 2a77ebcb3ce941cccf20c6273fd37d73ea77b97f..b33c165a283186588c17e3f0732a79630e14ca29 100644 (file)
@@ -33,7 +33,7 @@ int usage_t55xx_config(){
        PrintAndLog("       h                        This help");\r
        PrintAndLog("       d <FSK|ASK|PSK|NZ|BI>    Set demodulation FSK / ASK / PSK / NZ / Biphase");\r
        PrintAndLog("       i [1]                    Inverse data signal, defaults to normal");\r
        PrintAndLog("       h                        This help");\r
        PrintAndLog("       d <FSK|ASK|PSK|NZ|BI>    Set demodulation FSK / ASK / PSK / NZ / Biphase");\r
        PrintAndLog("       i [1]                    Inverse data signal, defaults to normal");\r
-       PrintAndLog("       o [offsett]              Set offset, where data should start decode from in bitstream");\r
+       PrintAndLog("       o [offset]               Set offset, where data should start decode in bitstream");\r
        PrintAndLog("");\r
        PrintAndLog("Examples:");\r
        PrintAndLog("      lf t55xx config d FSK          - FSK demodulation");\r
        PrintAndLog("");\r
        PrintAndLog("Examples:");\r
        PrintAndLog("      lf t55xx config d FSK          - FSK demodulation");\r
@@ -109,61 +109,51 @@ static int CmdHelp(const char *Cmd);
 \r
 int CmdT55xxSetConfig(const char *Cmd){\r
 \r
 \r
 int CmdT55xxSetConfig(const char *Cmd){\r
 \r
-       uint8_t data[] = {0x78,0x00,0x00,0x00,0x00,0x00,0x00};\r
-       uint8_t cmd[]  = {0x00,0x00};\r
-       ComputeCrc14443(CRC_14443_B, data, 7 , &cmd[0], &cmd[1]);\r
-       PrintAndLog("%02X %02X",cmd[0], cmd[1]);\r
-       int len = 0;\r
-       int foundModulation = 2;\r
        uint8_t offset = 0;\r
        uint8_t offset = 0;\r
-       bool inverse = FALSE;\r
        bool errors = FALSE;\r
        uint8_t cmdp = 0;\r
        char modulation[4] = {0x00};\r
        bool errors = FALSE;\r
        uint8_t cmdp = 0;\r
        char modulation[4] = {0x00};\r
+       char tmp = 0x00;\r
        \r
        while(param_getchar(Cmd, cmdp) != 0x00 && !errors)\r
        {\r
        \r
        while(param_getchar(Cmd, cmdp) != 0x00 && !errors)\r
        {\r
-               switch(param_getchar(Cmd, cmdp))\r
+               tmp = param_getchar(Cmd, cmdp);\r
+               switch(tmp)\r
                {\r
                case 'h':\r
                case 'H':\r
                        return usage_t55xx_config();\r
                case 'd':\r
                {\r
                case 'h':\r
                case 'H':\r
                        return usage_t55xx_config();\r
                case 'd':\r
-                       len = param_getstr(Cmd, cmdp+1, modulation);\r
-                       cmdp+= len+1;\r
-                       //FSK|ASK|PSK|NZ|BI\r
-                       if ( strcmp(modulation, "FSK" ) == 0)\r
-                               foundModulation = 1;\r
-                       else if ( strcmp(modulation, "ASK" ) == 0)\r
-                               foundModulation = 2;\r
-                       else if ( strcmp(modulation, "PSK" ) == 0)\r
-                               foundModulation = 3;\r
-                       else if ( strcmp(modulation, "NZ" ) == 0)\r
-                               foundModulation = 4;\r
-                       else if ( strcmp(modulation, "BI" ) == 0)\r
-                               foundModulation = 5;\r
+                       param_getstr(Cmd, cmdp+1, modulation);\r
+                       cmdp += 2;\r
+                       \r
+                       if ( strcmp(modulation, "FSK" ) == 0)       config.modulation = DEMOD_FSK;\r
+                       else if ( strcmp(modulation, "ASK" ) == 0)  config.modulation = DEMOD_ASK;\r
+                       else if ( strcmp(modulation, "PSK" ) == 0)  config.modulation = DEMOD_PSK;\r
+                       else if ( strcmp(modulation, "NZ" ) == 0)       config.modulation = DEMOD_NZR;\r
+                       else if ( strcmp(modulation, "BI" ) == 0)       config.modulation = DEMOD_BI;\r
                        else {\r
                                PrintAndLog("Unknown modulation '%s'", modulation);\r
                                errors = TRUE;\r
                        }\r
                        break;\r
                case 'i':\r
                        else {\r
                                PrintAndLog("Unknown modulation '%s'", modulation);\r
                                errors = TRUE;\r
                        }\r
                        break;\r
                case 'i':\r
-                       inverse = param_getchar(Cmd,cmdp+1) == '1';\r
+                       config.inversed = param_getchar(Cmd,cmdp+1) == '1';\r
                        cmdp+=2;\r
                        break;\r
                case 'o':\r
                        errors |= param_getdec(Cmd, cmdp+1,&offset);\r
                        cmdp+=2;\r
                        break;\r
                case 'o':\r
                        errors |= param_getdec(Cmd, cmdp+1,&offset);\r
-                       if ( offset >= 32 ){\r
-                               PrintAndLog("Offset must be smaller than 32");\r
-                               errors = TRUE;\r
-                       }\r
-                       cmdp+=2;\r
+                       if ( !errors )\r
+                               config.offset = offset;\r
+                       cmdp += 2;\r
                        break;\r
                default:\r
                        PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
                        errors = TRUE;\r
                        break;\r
                }\r
                        break;\r
                default:\r
                        PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
                        errors = TRUE;\r
                        break;\r
                }\r
+               \r
+               PrintAndLog(" %c  %d  [%d]", param_getchar(Cmd, cmdp) , errors, cmdp);\r
        }\r
        // No args\r
        if (cmdp == 0) {\r
        }\r
        // No args\r
        if (cmdp == 0) {\r
@@ -174,10 +164,8 @@ int CmdT55xxSetConfig(const char *Cmd){
        if (errors)\r
                return usage_t55xx_config();\r
  \r
        if (errors)\r
                return usage_t55xx_config();\r
  \r
-       config.modulation = foundModulation;\r
-       config.inversed = inverse;\r
-       config.offset = offset;\r
        config.block0 = 0;\r
        config.block0 = 0;\r
+       printConfiguration( config );\r
        return 0;\r
 }\r
 \r
        return 0;\r
 }\r
 \r
@@ -377,7 +365,11 @@ bool test(){
        if ( !DemodBufferLen) \r
                return false;\r
        \r
        if ( !DemodBufferLen) \r
                return false;\r
        \r
-       uint8_t si = 1;\r
+       if ( PackBits(0, 32, DemodBuffer) == 0x00 )\r
+               return FALSE;\r
+       \r
+       uint8_t si = 0;\r
+       \r
        uint8_t safer    = PackBits(si, 4, DemodBuffer); si += 4;       \r
        uint8_t resv     = PackBits(si, 7, DemodBuffer); si += 7+3;\r
        uint8_t extend   = PackBits(si, 1, DemodBuffer); si += 1;\r
        uint8_t safer    = PackBits(si, 4, DemodBuffer); si += 4;       \r
        uint8_t resv     = PackBits(si, 7, DemodBuffer); si += 7+3;\r
        uint8_t extend   = PackBits(si, 1, DemodBuffer); si += 1;\r
@@ -411,7 +403,7 @@ void printT55xxBlock(const char *demodStr){
        int i = config.offset;\r
        int pos = 32 + config.offset;\r
     for (; i < pos; ++i)\r
        int i = config.offset;\r
        int pos = 32 + config.offset;\r
     for (; i < pos; ++i)\r
-               bits[i]=DemodBuffer[i];\r
+               bits[i - config.offset]=DemodBuffer[i];\r
        \r
        blockData = PackBits(0, 32, bits);\r
        PrintAndLog("0x%08X  %s [%s]", blockData, sprint_bin(bits,32), demodStr);\r
        \r
        blockData = PackBits(0, 32, bits);\r
        PrintAndLog("0x%08X  %s [%s]", blockData, sprint_bin(bits,32), demodStr);\r
@@ -419,12 +411,12 @@ void printT55xxBlock(const char *demodStr){
 \r
 int special(const char *Cmd) {\r
        uint32_t blockData = 0;\r
 \r
 int special(const char *Cmd) {\r
        uint32_t blockData = 0;\r
-       uint8_t bits[64] = {0x00};\r
+       uint8_t bits[32] = {0x00};\r
 \r
        PrintAndLog("[OFFSET] [DATA] [BINARY]");\r
        PrintAndLog("----------------------------------------------------");\r
        int i,j = 0;\r
 \r
        PrintAndLog("[OFFSET] [DATA] [BINARY]");\r
        PrintAndLog("----------------------------------------------------");\r
        int i,j = 0;\r
-       for (; j < 32; ++j){\r
+       for (; j < 128; ++j){\r
                \r
                for (i = 0; i < 32; ++i)\r
                        bits[i]=DemodBuffer[j+i];\r
                \r
                for (i = 0; i < 32; ++i)\r
                        bits[i]=DemodBuffer[j+i];\r
@@ -514,7 +506,7 @@ int CmdT55xxReadTrace(const char *Cmd)
        \r
        RepaintGraphWindow();\r
 \r
        \r
        RepaintGraphWindow();\r
 \r
-       uint8_t si = 5;\r
+       uint8_t si = config.offset;\r
        uint32_t bl0     = PackBits(si, 32, DemodBuffer);\r
        uint32_t bl1     = PackBits(si+32, 32, DemodBuffer);\r
        \r
        uint32_t bl0     = PackBits(si, 32, DemodBuffer);\r
        uint32_t bl1     = PackBits(si+32, 32, DemodBuffer);\r
        \r
@@ -608,7 +600,7 @@ int CmdT55xxInfo(const char *Cmd){
                return 2;\r
        \r
        \r
                return 2;\r
        \r
        \r
-       uint8_t si = 1;\r
+       uint8_t si = config.offset;\r
        uint32_t bl0      = PackBits(si, 32, DemodBuffer);\r
        \r
        uint32_t safer    = PackBits(si, 4, DemodBuffer); si += 4;      \r
        uint32_t bl0      = PackBits(si, 32, DemodBuffer);\r
        \r
        uint32_t safer    = PackBits(si, 4, DemodBuffer); si += 4;      \r
Impressum, Datenschutz