- if (ReceiveCommandPoll(&cmdbuf)) {
- for (int i = 0; i < strlen(PROXPROMPT); i++)
- putchar(0x08);
- UsbCommandReceived(&cmdbuf);
- // there is a big bug )
- if (cmdbuf.cmd >= 0x0100 && cmdbuf.cmd <= 0x0110) { // debug commands
- printf(">");
-// rl_on_new_line_with_prompt();
-// rl_forced_update_display();
- }
- fflush(NULL);
+ 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;