- struct receiver_arg *arg = (struct receiver_arg*)targ;
- size_t rxlen;
- size_t cmd_count;
-
- while (arg->run) {
- rxlen = sizeof(UsbCommand);
- if (uart_receive(sp,prx,&rxlen)) {
- prx += rxlen;
- if (((prx-rx) % sizeof(UsbCommand)) != 0) {
- continue;
- }
- cmd_count = (prx-rx) / sizeof(UsbCommand);
-
- for (size_t i=0; i<cmd_count; i++) {
- UsbCommandReceived((UsbCommand*)(rx+(i*sizeof(UsbCommand))));
- }
- }
- prx = rx;
-
- if(txcmd_pending) {
- if (!uart_send(sp,(byte_t*)&txcmd,sizeof(UsbCommand))) {
- PrintAndLog("Sending bytes to proxmark failed");
- }
- txcmd_pending = false;
- }
- }
-
- pthread_exit(NULL);
- return NULL;
+ struct receiver_arg *arg = (struct receiver_arg*)targ;
+ size_t rxlen;
+ size_t cmd_count;
+
+ while (arg->run) {
+
+ rxlen = sizeof(UsbCommand);
+
+ if (uart_receive(sp, prx, &rxlen)) {
+ prx += rxlen;
+ if (((prx-rx) % sizeof(UsbCommand)) != 0)
+ continue;
+
+ cmd_count = (prx-rx) / sizeof(UsbCommand);
+
+ for (size_t i = 0; i < cmd_count; i++)
+ UsbCommandReceived((UsbCommand*)( rx + ( i * sizeof(UsbCommand))));
+
+ }
+ prx = rx;
+
+ if (txcmd_pending) {
+ bool res = uart_send(sp, (byte_t*) &txcmd, sizeof(UsbCommand));
+ if (!res) {
+ PrintAndLog("Sending bytes to proxmark failed");
+ }
+ txcmd_pending = false;
+ }
+ }
+ pthread_exit(NULL);
+ return NULL;