]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdlfem4x.c
chg: LF t55xx trace
[proxmark3-svn] / client / cmdlfem4x.c
index be31e1eacc935493363b0fcf9a9c0aab21dedd6b..8380bcba87e793eccd0b6200a261a7284bfb4f23 100644 (file)
@@ -21,6 +21,7 @@
 #include "cmdlfem4x.h"
 #include "util.h"
 #include "data.h"
 #include "cmdlfem4x.h"
 #include "util.h"
 #include "data.h"
+#define LF_TRACE_BUFF_SIZE 12000
 
 char *global_em410xId;
 
 
 char *global_em410xId;
 
@@ -506,84 +507,80 @@ int CmdEM410xWrite(const char *Cmd)
 int CmdReadWord(const char *Cmd)
 {
        int Word = -1; //default to invalid word
 int CmdReadWord(const char *Cmd)
 {
        int Word = -1; //default to invalid word
-  UsbCommand c;
+       UsbCommand c;
   
   
-  sscanf(Cmd, "%d", &Word);
+       sscanf(Cmd, "%d", &Word);
   
        if ( (Word > 15) | (Word < 0) ) {
   
        if ( (Word > 15) | (Word < 0) ) {
-    PrintAndLog("Word must be between 0 and 15");
-    return 1;
-  }
+               PrintAndLog("Word must be between 0 and 15");
+               return 1;
+       }
   
   
-  PrintAndLog("Reading word %d", Word);
+       PrintAndLog("Reading word %d", Word);
   
   
-  c.cmd = CMD_EM4X_READ_WORD;
-  c.d.asBytes[0] = 0x0; //Normal mode
-  c.arg[0] = 0;
-  c.arg[1] = Word;
-  c.arg[2] = 0;
-  SendCommand(&c);
+       c.cmd = CMD_EM4X_READ_WORD;
+       c.d.asBytes[0] = 0x0; //Normal mode
+       c.arg[0] = 0;
+       c.arg[1] = Word;
+       c.arg[2] = 0;
+       SendCommand(&c);
        WaitForResponse(CMD_ACK, NULL);
 
        WaitForResponse(CMD_ACK, NULL);
 
-       size_t bytelength = 4096;
-       uint8_t data[bytelength];
-       memset(data, 0x00, bytelength);
+       uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00};
 
 
-       GetFromBigBuf(data,bytelength,3560);  //3560 -- should be offset..
+       GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560);  //3560 -- should be offset..
        WaitForResponseTimeout(CMD_ACK,NULL, 1500);
 
        WaitForResponseTimeout(CMD_ACK,NULL, 1500);
 
-       for (int j = 0; j < bytelength; j++) {
-               GraphBuffer[j] = ((int)data[j]) - 128;
+       for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {
+               GraphBuffer[j] = ((int)data[j]);
        }
        }
-       GraphTraceLen = bytelength;
-       RepaintGraphWindow();
-
-       manchester_decode(data, bytelength);
-
-       free(data);
+       GraphTraceLen = LF_TRACE_BUFF_SIZE;
        
        
+       uint8_t bits[1000] = {0x00};
+       uint8_t * bitstream = bits;
+       manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream);
+       RepaintGraphWindow();
   return 0;
 }
 
 int CmdReadWordPWD(const char *Cmd)
 {
        int Word = -1; //default to invalid word
   return 0;
 }
 
 int CmdReadWordPWD(const char *Cmd)
 {
        int Word = -1; //default to invalid word
-  int Password = 0xFFFFFFFF; //default to blank password
-  UsbCommand c;
-  
-  sscanf(Cmd, "%d %x", &Word, &Password);
-  
+       int Password = 0xFFFFFFFF; //default to blank password
+       UsbCommand c;
+
+       sscanf(Cmd, "%d %x", &Word, &Password);
+
        if ( (Word > 15) | (Word < 0) ) {
        if ( (Word > 15) | (Word < 0) ) {
-    PrintAndLog("Word must be between 0 and 15");
-    return 1;
-  }
-  
-  PrintAndLog("Reading word %d with password %08X", Word, Password);
+               PrintAndLog("Word must be between 0 and 15");
+               return 1;
+       }
   
   
-  c.cmd = CMD_EM4X_READ_WORD;
-  c.d.asBytes[0] = 0x1; //Password mode
-  c.arg[0] = 0;
-  c.arg[1] = Word;
-  c.arg[2] = Password;
-  SendCommand(&c);
+       PrintAndLog("Reading word %d with password %08X", Word, Password);
+
+       c.cmd = CMD_EM4X_READ_WORD;
+       c.d.asBytes[0] = 0x1; //Password mode
+       c.arg[0] = 0;
+       c.arg[1] = Word;
+       c.arg[2] = Password;
+       SendCommand(&c);
        WaitForResponse(CMD_ACK, NULL);
        WaitForResponse(CMD_ACK, NULL);
+               
+       uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00};
 
 
-       size_t bytelength = 4096;
-       uint8_t data[bytelength];
-       memset(data, 0x00, bytelength);
-
-       GetFromBigBuf(data,bytelength,3560);  //3560 -- should be offset..
+       GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560);  //3560 -- should be offset..
        WaitForResponseTimeout(CMD_ACK,NULL, 1500);
 
        WaitForResponseTimeout(CMD_ACK,NULL, 1500);
 
-       for (int j = 0; j < bytelength; j++) {
-               GraphBuffer[j] = ((int)data[j]) - 128;
+       for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {
+               GraphBuffer[j] = ((int)data[j]);
        }
        }
-       GraphTraceLen = bytelength;
+       GraphTraceLen = LF_TRACE_BUFF_SIZE;
+       
+       uint8_t bits[1000] = {0x00};
+       uint8_t * bitstream = bits;
+       
+       manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream);
        RepaintGraphWindow();
        RepaintGraphWindow();
-
-       manchester_decode(data, bytelength);
-
-       free(data);
   return 0;
 }
 
   return 0;
 }
 
@@ -636,8 +633,6 @@ int CmdWriteWordPWD(const char *Cmd)
   return 0;
 }
 
   return 0;
 }
 
-
-
 static command_t CommandTable[] =
 {
   {"help", CmdHelp, 1, "This help"},
 static command_t CommandTable[] =
 {
   {"help", CmdHelp, 1, "This help"},
Impressum, Datenschutz