]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - common/cmd.c
FIX: lf hitag : Mea culpa, simulation should not have reader_field on. thanks to...
[proxmark3-svn] / common / cmd.c
index dae3a8daafaa707ecb8350bf99e42347973a5303..2111a8f58d398bb4d684fcd01399525fc31e9e12 100644 (file)
  */\r
 \r
 #include "cmd.h"\r
-#include "string.h"\r
-#include "../include/proxmark3.h"\r
-\r
-//static UsbCommand txcmd;\r
 \r
 bool cmd_receive(UsbCommand* cmd) {\r
  \r
@@ -52,30 +48,32 @@ bool cmd_receive(UsbCommand* cmd) {
 }\r
 \r
 bool cmd_send(uint32_t cmd, uint32_t arg0, uint32_t arg1, uint32_t arg2, void* data, size_t len) {\r
-  UsbCommand txcmd;\r
 \r
-  for (size_t i=0; i<sizeof(UsbCommand); i++) {\r
-    ((byte_t*)&txcmd)[i] = 0x00;\r
-  }\r
-  \r
-  // Compose the outgoing command frame\r
-  txcmd.cmd = cmd;\r
-  txcmd.arg[0] = arg0;\r
-  txcmd.arg[1] = arg1; \r
-  txcmd.arg[2] = arg2;\r
+       UsbCommand txcmd;\r
 \r
-  // Add the (optional) content to the frame, with a maximum size of USB_CMD_DATA_SIZE\r
-  if (data && len) {\r
-    len = MIN(len,USB_CMD_DATA_SIZE);\r
-    for (size_t i=0; i<len; i++) {\r
-      txcmd.d.asBytes[i] = ((byte_t*)data)[i];\r
-    }\r
-  }\r
-  \r
-  // Send frame and make sure all bytes are transmitted\r
-  if (usb_write((byte_t*)&txcmd,sizeof(UsbCommand)) != 0) return false;\r
-  \r
-  return true;\r
+       // 0x00 the whole command.\r
+       for (size_t i=0; i < sizeof(UsbCommand); i++)\r
+               ((byte_t*)&txcmd)[i] = 0x00;\r
+\r
+       // Compose the outgoing command frame\r
+       txcmd.cmd = cmd;\r
+       txcmd.arg[0] = arg0;\r
+       txcmd.arg[1] = arg1;    \r
+       txcmd.arg[2] = arg2;\r
+\r
+       // Add the (optional) content to the frame, with a maximum size of USB_CMD_DATA_SIZE\r
+       if (data && len) {\r
+               len = MIN(len, USB_CMD_DATA_SIZE);\r
+               for (size_t i=0; i<len; i++) {\r
+                       txcmd.d.asBytes[i] = ((byte_t*)data)[i];\r
+               }\r
+       }\r
+\r
+       // Send frame and make sure all bytes are transmitted\r
+       if ( usb_write( (byte_t*)&txcmd, sizeof(UsbCommand)) != 0)\r
+               return false;\r
+\r
+       return true;\r
 }\r
 \r
 \r
Impressum, Datenschutz