+void SendCommand(UsbCommand* txcmd) {
+// printf("send: ");
+// cmd_debug(txcmd);
+ if (!uart_send(sp,(uint8_t*)txcmd,sizeof(UsbCommand))) {
+ printf("Sending bytes to proxmark failed\n");
+ exit(1);
+ }
+}
+
+void ReceiveCommand(UsbCommand* rxcmd) {
+ uint8_t* prxcmd = (uint8_t*)rxcmd;
+ uint8_t* prx = prxcmd;
+ size_t rxlen;
+ while (true) {
+ if (uart_receive(sp, prx, sizeof(UsbCommand) - (prx-prxcmd), &rxlen)) {
+ prx += rxlen;
+ if ((prx-prxcmd) >= sizeof(UsbCommand)) {
+ return;
+ }
+ }
+ }
+}
+