]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
ADD: printConfiguration method for a nice printout of the selected configuration.
authoriceman1001 <iceman@iuse.se>
Fri, 13 Mar 2015 18:12:11 +0000 (19:12 +0100)
committericeman1001 <iceman@iuse.se>
Fri, 13 Mar 2015 18:12:11 +0000 (19:12 +0100)
client/cmdlft55xx.c
client/cmdlft55xx.h

index ced17ef5e8d742ce629975a7116b64c373fdac61..5ecf290a2f3e27568973e01d533e9dc72d9fa2af 100644 (file)
 #define LF_TRACE_BUFF_SIZE 20000 // 32 x 32 x 10  (32 bit times numofblock (7), times clock skip..)\r
 #define LF_BITSSTREAM_LEN 1000 // more then 1000 bits shouldn't happend..  8block * 4 bytes * 8bits = \r
 \r
-//  0 = FSK\r
-//  1 = ASK\r
-//  2 = PSK\r
-//  4 = NZR (direct)\r
-typedef struct {\r
-       uint8_t modulation;\r
-       bool inversed;\r
-       uint32_t block0;\r
-} t55xx_conf_block_t;\r
-\r
-// Default configuration: FSK, not inversed.\r
+\r
+\r
+// Default configuration: ASK, not inversed.\r
 t55xx_conf_block_t config = { .modulation = 2, .inversed = FALSE, .block0 = 0x00};\r
 \r
 int usage_t55xx_config(){\r
@@ -164,9 +156,7 @@ int CmdT55xxSetConfig(const char *Cmd){
        }\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
+               printConfiguration( config );\r
                return 0;\r
        }\r
        //Validations\r
@@ -351,16 +341,16 @@ bool tryDetectModulation(){
                // }\r
        }               \r
        if ( hits == 1) {\r
-               PrintAndLog("Modulation: %d  Inverse: %d", tests[0].modulation, tests[0].inversed);\r
                config.modulation = tests[0].modulation;\r
                config.inversed = tests[0].inversed;\r
+               printConfiguration( config );\r
                return TRUE;\r
        }\r
        \r
        if ( hits > 1) {\r
                PrintAndLog("Found [%d] possible matches for modulation.",hits);\r
                for(int i=0; i<hits; ++i){\r
-                       PrintAndLog("Modulation: %d  Inverse: %d", tests[i].modulation, tests[i].inversed);\r
+                       printConfiguration( tests[i] );\r
                }\r
        }\r
        return FALSE;\r
@@ -405,6 +395,13 @@ void printT55xxBlock(const char *demodStr){
        PrintAndLog("0x%08X  %s [%s]", blockData, sprint_bin(bits+1,32), demodStr);\r
 }\r
 \r
+void printConfiguration( t55xx_conf_block_t b){\r
+       PrintAndLog("Modulation : %s", GetSelectedModulationStr(b.modulation) );\r
+       PrintAndLog("Inverted   : %s", (b.inversed) ? "Yes" : "No" );\r
+       PrintAndLog("Block0     : %08X", b.block0);\r
+       PrintAndLog("");\r
+}\r
+\r
 /*\r
 FSK1 / FSK1a\r
 size = fskdemod(dest, size, 32, 0, 8, 10);  // fsk1 RF/32 \r
@@ -752,6 +749,34 @@ char * GetModulationStr( uint32_t id){
        return buf;\r
 }\r
 \r
+char * GetSelectedModulationStr( uint8_t id){\r
+\r
+       static char buf[16];\r
+       char *retStr = buf;\r
+       \r
+       switch (id){\r
+               case 1:\r
+                       sprintf(retStr,"FSK (%d)",id);\r
+                       break;\r
+               case 2:         \r
+                       sprintf(retStr,"ASK (%d)",id);\r
+                       break;\r
+               case 3:\r
+                       sprintf(retStr,"DIRECT/NRZ (%d)",id);\r
+                       break;\r
+               case 4:\r
+                       sprintf(retStr,"PSK (%d)",id);\r
+                       break;\r
+               case 5:\r
+                       sprintf(retStr,"BIPHASE (%d)",id);\r
+                       break;\r
+               default:\r
+                       sprintf(retStr,"(Unknown)");\r
+                       break;\r
+               }\r
+       return buf;\r
+}\r
+\r
 uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits){\r
        \r
        int i = start;\r
index e1f4d223d48fbc412111d03493af367d78c85a5d..ec74aed48e543a2355d3b5c21d2bdc065b5b9fab 100644 (file)
 #ifndef CMDLFT55XX_H__\r
 #define CMDLFT55XX_H__\r
 \r
+typedef struct {\r
+       uint8_t modulation;\r
+       bool inversed;\r
+       uint32_t block0;\r
+} t55xx_conf_block_t;\r
+\r
+\r
 int CmdLFT55XX(const char *Cmd);\r
 int CmdT55xxSetConfig(const char *Cmd);\r
 int CmdT55xxReadBlock(const char *Cmd);\r
@@ -21,8 +28,11 @@ int CmdT55xxDetect(const char *Cmd);
 char * GetBitRateStr(uint32_t id);\r
 char * GetSaferStr(uint32_t id);\r
 char * GetModulationStr( uint32_t id);\r
+char * GetSelectedModulationStr( uint8_t id);\r
 uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bitstream);\r
 void printT55xxBlock(const char *demodStr);\r
+void printConfiguration( t55xx_conf_block_t b);\r
+\r
 void DecodeT55xxBlock();\r
 bool tryDetectModulation();\r
 bool test();\r
Impressum, Datenschutz