#include "string.h"\r
#include "proxmark3.h"\r
\r
-//static UsbCommand txcmd;\r
-\r
bool cmd_receive(UsbCommand* cmd) {\r
\r
// Check if there is a usb packet available\r
}\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