- // 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