]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
additional Q5 `lf t55xx` fixes
authormarshmellow42 <marshmellowrf@gmail.com>
Mon, 14 Dec 2015 22:36:08 +0000 (17:36 -0500)
committermarshmellow42 <marshmellowrf@gmail.com>
Mon, 14 Dec 2015 22:36:08 +0000 (17:36 -0500)
client/cmdlft55xx.c

index 8b23c175f3059920cc797788da13e594f33262b4..0d277d06bf8e40363f70ba426eb42bba206ef75c 100644 (file)
@@ -183,7 +183,6 @@ int CmdT55xxSetConfig(const char *Cmd) {
        uint8_t bitRate = 0;\r
        uint8_t rates[9] = {8,16,32,40,50,64,100,128,0};\r
        uint8_t cmdp = 0;\r
-       config.Q5 = FALSE;\r
        bool errors = FALSE;\r
        while(param_getchar(Cmd, cmdp) != 0x00 && !errors)\r
        {\r
@@ -672,6 +671,15 @@ bool testQ5Modulation(uint8_t      mode, uint8_t   modread){
        return FALSE;\r
 }\r
 \r
+int convertQ5bitRate(uint8_t bitRateRead) {\r
+       uint8_t expected[] = {8, 16, 32, 40, 50, 64, 100, 128};\r
+       for (int i=0; i<8; i++)\r
+               if (expected[i] == bitRateRead)\r
+                       return i;\r
+\r
+       return -1;\r
+}\r
+\r
 bool testQ5(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t    clk){\r
 \r
        if ( DemodBufferLen < 64 ) return FALSE;\r
@@ -703,7 +711,8 @@ bool testQ5(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk){
                //test modulation\r
                if (!testQ5Modulation(mode, modread)) continue;\r
                if (bitRate != clk) continue;\r
-               *fndBitRate = bitRate;\r
+               *fndBitRate = convertQ5bitRate(bitRate);\r
+               if (*fndBitRate < 0) continue;\r
                *offset = idx;\r
 \r
                return TRUE;\r
@@ -1109,44 +1118,25 @@ int AquireData( uint8_t page, uint8_t block, bool pwdmode, uint32_t password ){
        return 1;\r
 }\r
 \r
-char * GetBitRateStr(uint32_t id){\r
-       static char buf[25];\r
+char * GetBitRateStr(uint32_t id) {\r
+       static char buf[25];\r
 \r
        char *retStr = buf;\r
-               switch (id){\r
-               case 0: \r
-                       snprintf(retStr,sizeof(buf),"%d - RF/8",id);\r
-                       break;\r
-               case 1:\r
-                       snprintf(retStr,sizeof(buf),"%d - RF/16",id);\r
-                       break;\r
-               case 2:         \r
-                       snprintf(retStr,sizeof(buf),"%d - RF/32",id);\r
-                       break;\r
-               case 3:\r
-                       snprintf(retStr,sizeof(buf),"%d - RF/40",id);\r
-                       break;\r
-               case 4:\r
-                       snprintf(retStr,sizeof(buf),"%d - RF/50",id);\r
-                       break;\r
-               case 5:\r
-                       snprintf(retStr,sizeof(buf),"%d - RF/64",id);\r
-                       break;\r
-               case 6:\r
-                       snprintf(retStr,sizeof(buf),"%d - RF/100",id);\r
-                       break;\r
-               case 7:\r
-                       snprintf(retStr,sizeof(buf),"%d - RF/128",id);\r
-                       break;\r
-               default:\r
-                       snprintf(retStr,sizeof(buf),"%d - (Unknown)",id);\r
-                       break;\r
-               }\r
-\r
+       switch (id) {\r
+               case 0:   snprintf(retStr,sizeof(buf),"%d - RF/8",id);   break;\r
+               case 1:   snprintf(retStr,sizeof(buf),"%d - RF/16",id);  break;\r
+               case 2:   snprintf(retStr,sizeof(buf),"%d - RF/32",id);  break;\r
+               case 3:   snprintf(retStr,sizeof(buf),"%d - RF/40",id);  break;\r
+               case 4:   snprintf(retStr,sizeof(buf),"%d - RF/50",id);  break;\r
+               case 5:   snprintf(retStr,sizeof(buf),"%d - RF/64",id);  break;\r
+               case 6:   snprintf(retStr,sizeof(buf),"%d - RF/100",id); break;\r
+               case 7:   snprintf(retStr,sizeof(buf),"%d - RF/128",id); break;\r
+               default:  snprintf(retStr,sizeof(buf),"%d - (Unknown)",id); break;\r
+       }\r
        return buf;\r
 }\r
 \r
-char * GetSaferStr(uint32_t id){\r
+char * GetSaferStr(uint32_t id) {\r
        static char buf[40];\r
        char *retStr = buf;\r
        \r
Impressum, Datenschutz