static void *uart_receiver(void *targ) { 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); // printf("received %d bytes, which represents %d commands\n",(prx-rx), cmd_count); 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; }
static void *usb_receiver(void *targ) { struct usb_receiver_arg *arg = (struct usb_receiver_arg*)targ; UsbCommand cmdbuf; while (arg->run) { if (ReceiveCommandPoll(&cmdbuf)) { UsbCommandReceived(&cmdbuf); fflush(NULL); } } pthread_exit(NULL); return NULL; }