]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
ADD: LF T55XX CONFIG, is almost there, Usage: lf t55xx config [d <demodulation...
authoriceman1001 <iceman@iuse.se>
Thu, 12 Mar 2015 18:44:07 +0000 (19:44 +0100)
committericeman1001 <iceman@iuse.se>
Thu, 12 Mar 2015 18:44:07 +0000 (19:44 +0100)
Options:
       h                        This help
       d <FSK|ASK|PSK|NZ|BI>    Set demodulation FSK / ASK / PSK / NZ / Biphase
       i [1]                    Inverse data signal, defaults to normal

Examples:
      lf t55xx config d FSK     - FSK demodulation
      lf t55xx config d FSK i 1 - FSK demodulation, inverse data

client/cmdlft55xx.c

index 61c8ec2b352372eeafd0e1a87dfb5b4ce7631f15..7a377cc9bac4d6187596acb3950bd4bc05dd3a33 100644 (file)
@@ -34,45 +34,22 @@ typedef struct {
        uint8_t modulation;\r
        bool inversed;\r
        uint32_t block0;\r
-} t55xx_conf_block;\r
+} t55xx_conf_block_t;\r
 \r
 // Default configuration: FSK, not inversed.\r
-t55xx_conf_block config = {0x00, FALSE, 0x00};\r
-\r
-       // FSK\r
-       // FSK inverted\r
-       //FSKrawDemod("", FALSE)\r
-       //FSKrawDemod("1", FALSE)\r
-\r
-       // ASK/MAN\r
-       // ASK/MAN inverted\r
-       //ASKmanDemod("", FALSE, FALSE)\r
-       \r
-       // NZR (autoclock, normal, maxerrors 1)\r
-       // NZR (autoclock, inverse, maxerrors 1)\r
-       //NRZrawDemod("0 0 1", FALSE) ) {\r
-               \r
-       // PSK (autoclock, normal, maxerrors 1)\r
-       // PSK (autoclock, inverse, maxerrors 1)\r
-       //PSKDemod("0 0 1", FALSE)\r
+t55xx_conf_block_t config = { .modulation = 0, .inversed = FALSE, .block0 = 0x00};\r
 \r
 int usage_t55xx_config(){\r
-       PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 0|1]");\r
+       PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 1]");\r
        PrintAndLog("Options:        ");\r
-       PrintAndLog("       h             This help");\r
-       PrintAndLog("       d <>          Set demodulation FSK / ASK / PSK / NZR");\r
-       PrintAndLog("       i [0|1]       Inverse data signal, Default: 0");\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("");\r
        PrintAndLog("Examples:");\r
-       PrintAndLog("      lf t55xx config d FSK ");\r
-       PrintAndLog("                    FSK demodulation");\r
-       PrintAndLog("      lf t55xx config d FSK i 1");\r
-       PrintAndLog("                    FSK demodulation, inverse data");\r
-       PrintAndLog("      lf dump");\r
-       PrintAndLog("                    Dumps all block from tag");\r
-       PrintAndLog("      lf trace");\r
-       PrintAndLog("                    Read trace block and decode it");\r
-       PrintAndLog("      lf info");\r
-       PrintAndLog("                    Read configuration and decode it");\r
+       PrintAndLog("      lf t55xx config d FSK     - FSK demodulation");\r
+       PrintAndLog("      lf t55xx config d FSK i 1 - FSK demodulation, inverse data");\r
+       PrintAndLog("");\r
        return 0;\r
 }\r
 int usage_t55xx_read(){\r
@@ -80,8 +57,9 @@ int usage_t55xx_read(){
     PrintAndLog("     <block>, block number to read. Between 0-7");\r
     PrintAndLog("     <password>, OPTIONAL password (8 hex characters)");\r
     PrintAndLog("");\r
-    PrintAndLog("    sample: lf t55xx read 0           = try reading data from block 0");\r
-       PrintAndLog("          : lf t55xx read 0 feedbeef  = try reading data from block 0 using password");\r
+       PrintAndLog("Examples:");\r
+    PrintAndLog("      lf t55xx read 0           - read data from block 0");\r
+       PrintAndLog("      lf t55xx read 0 feedbeef  - read data from block 0 password feedbeef");\r
        PrintAndLog("");\r
        return 0;\r
 }\r
@@ -91,35 +69,39 @@ int usage_t55xx_write(){
        PrintAndLog("     <data>,  4 bytes of data to write (8 hex characters)");\r
     PrintAndLog("     [password], OPTIONAL password 4bytes (8 hex characters)");\r
     PrintAndLog("");\r
-    PrintAndLog("    sample: lf t55xx wd 3 11223344  = try writing data 11223344 to block 3");\r
-       PrintAndLog("          : lf t55xx wd 3 11223344 feedbeef  = try writing data 11223344 to block 3 using password feedbeef");\r
+       PrintAndLog("Examples:");\r
+    PrintAndLog("      lf t55xx wd 3 11223344           - write 11223344 to block 3");\r
+       PrintAndLog("      lf t55xx wd 3 11223344 feedbeef  - write 11223344 to block 3 password feedbeef");\r
        PrintAndLog("");\r
        return 0;\r
 }\r
 int usage_t55xx_trace() {\r
-       PrintAndLog("Usage:  lf t55xx trace  [graph buffer data]");\r
+       PrintAndLog("Usage:  lf t55xx trace [1]");\r
        PrintAndLog("     [graph buffer data], if set, use Graphbuffer otherwise read data from tag.");\r
        PrintAndLog("");\r
-       PrintAndLog("     sample: lf t55xx trace");\r
-       PrintAndLog("           : lf t55xx trace 1");\r
+       PrintAndLog("Examples:");\r
+       PrintAndLog("      lf t55xx trace");\r
+       PrintAndLog("      lf t55xx trace 1");\r
        PrintAndLog("");\r
        return 0;\r
 }\r
 int usage_t55xx_info() {\r
-       PrintAndLog("Usage:  lf t55xx info [graph buffer data]");\r
+       PrintAndLog("Usage:  lf t55xx info [1]");\r
        PrintAndLog("     [graph buffer data], if set, use Graphbuffer otherwise read data from tag.");\r
        PrintAndLog("");\r
-       PrintAndLog("    sample: lf t55xx info");\r
-       PrintAndLog("          : lf t55xx info 1");\r
+       PrintAndLog("Examples:");\r
+       PrintAndLog("      lf t55xx info");\r
+       PrintAndLog("      lf t55xx info 1");\r
        PrintAndLog("");\r
        return 0;\r
 }\r
 int usage_t55xx_dump(){\r
        PrintAndLog("Usage:  lf t55xx dump <password>");\r
-    PrintAndLog("     <password>, OPTIONAL password 4bytes (8 hex characters)");\r
+    PrintAndLog("     <password>, OPTIONAL password 4bytes (8 hex symbols)");\r
        PrintAndLog("");\r
-       PrintAndLog("        sample: lf t55xx dump");\r
-       PrintAndLog("              : lf t55xx dump feedbeef");\r
+       PrintAndLog("Examples:");\r
+       PrintAndLog("      lf t55xx dump");\r
+       PrintAndLog("      lf t55xx dump feedbeef");\r
        PrintAndLog("");\r
        return 0;\r
 }\r
@@ -127,22 +109,65 @@ int usage_t55xx_dump(){
 static int CmdHelp(const char *Cmd);\r
 \r
 int CmdT55xxSetConfig(const char *Cmd){\r
+\r
+       int len;\r
+       bool inverse;\r
+       bool errors = FALSE;\r
+       uint8_t cmdp = 0;\r
+       char modulation[4] = {0x00};\r
        \r
-       uint8_t paramNum =0;\r
-       if(param_getchar(Cmd, paramNum) == 'h')\r
+       while(param_getchar(Cmd, cmdp) != 0x00 && !errors)\r
        {\r
-               return usage_t55xx_config();\r
+               switch(param_getchar(Cmd, cmdp))\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
+                               len = 1;\r
+                       else if ( strcmp(modulation, "ASK" ) == 0)\r
+                               len = 2;\r
+                       else if ( strcmp(modulation, "PSK" ) == 0)\r
+                               len = 3;\r
+                       else if ( strcmp(modulation, "NZ" ) == 0)\r
+                               len = 4;\r
+                       else if ( strcmp(modulation, "BI" ) == 0)\r
+                               len = 5;\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
+                       cmdp+=2;\r
+                       break;\r
+               default:\r
+                       PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
+                       errors = TRUE;\r
+                       break;\r
+               }\r
        }\r
-\r
-       uint8_t buff[] = { 0x01, 0x01, 0x01, 0x01,\r
-                                          0x01, 0x01, 0x01, 0x01,\r
-                                          0x01, 0x40, 0x01, 0x01, 0x04 };\r
-       PrintAndLog("CRC-8: %x",CRC8Maxim(buff, 13));\r
-\r
-       //config = { 0, FALSE};\r
+       // No args\r
+       if (cmdp == 0) {\r
+               PrintAndLog("Modulation: %d", config.modulation);\r
+               PrintAndLog("Invert    : %d", config.inversed);\r
+               PrintAndLog("Block0    : %08X", config.block0);\r
+               return 0;\r
+       }\r
+       //Validations\r
+       if (errors)\r
+               return usage_t55xx_config();\r
\r
+       config.modulation = len;\r
+       config.inversed = inverse;\r
+       config.block0 = 0;\r
        return 0;\r
 }\r
-\r
 // detect configuration?\r
 \r
 int CmdReadBlk(const char *Cmd)\r
@@ -188,17 +213,15 @@ int CmdReadBlk(const char *Cmd)
        setGraphBuf(got, 12000);\r
 \r
        if (block == 0){\r
-               // try a detection.\r
-               \r
+               // try a detection.     \r
        }\r
        \r
        if (CmdDetectClockRate("f")){ //wave is almost certainly FSK\r
-      //call FSK DEMOD\r
                // FSK\r
-               if ( FSKrawDemod("", FALSE))\r
+               if ( FSKrawDemod("0 0", FALSE))\r
                        printT55xx("FSK");\r
                // FSK inverted\r
-               if ( FSKrawDemod("1", FALSE)) \r
+               if ( FSKrawDemod("1", FALSE)) \r
                        printT55xx("FSK inv");\r
     } else {\r
                // ASK/MAN (autoclock, normal, maxerrors 1)\r
@@ -223,6 +246,14 @@ int CmdReadBlk(const char *Cmd)
                // PSK (autoclock, inverted, maxerrors 1)\r
                if (!PSKDemod("0 1 1", FALSE))\r
                        printT55xx("PSK inv");\r
+               \r
+               //PSK2?\r
+               \r
+               // if (!BiphaseRawDecode("0",FALSE))\r
+                       // printT55xx("BIPHASE");\r
+               \r
+               // if (!BiphaseRawDecode("1",FALSE))\r
+                       // printT55xx("BIPHASE inv");\r
        }\r
        return 0;\r
 }\r
Impressum, Datenschutz