From: adam@algroup.co.uk Date: Fri, 29 Jan 2010 09:28:47 +0000 (+0000) Subject: fix USB send data timing issue in CMD_DOWNLOADED_SIM_SAMPLES_125K X-Git-Tag: v1.0.0~393 X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/6982ac2612c12af9fa65437bf4279007d734cc59?ds=sidebyside;hp=13a79da4e974239d72bb0b132c02c67fb2600ad8 fix USB send data timing issue in CMD_DOWNLOADED_SIM_SAMPLES_125K --- diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 674c8917..4321d946 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -716,9 +716,12 @@ void UsbPacketReceived(BYTE *packet, int len) } case CMD_DOWNLOADED_SIM_SAMPLES_125K: { + UsbCommand ack; BYTE *b = (BYTE *)BigBuf; memcpy(b+c->arg[0], c->d.asBytes, 48); //Dbprintf("copied 48 bytes to %i",b+c->arg[0]); + ack.cmd = CMD_ACK; + UsbSendPacket((BYTE*)&ack, sizeof(ack)); break; } diff --git a/client/command.c b/client/command.c index 8ecbc684..0d954258 100644 --- a/client/command.c +++ b/client/command.c @@ -688,6 +688,7 @@ static void CmdLosim(char *str) /* convert to bitstream if necessary */ ChkBitstream(str); + PrintToScrollback("Sending data, please wait..."); for (i = 0; i < GraphTraceLen; i += 48) { UsbCommand c={CMD_DOWNLOADED_SIM_SAMPLES_125K, {i, 0, 0}}; int j; @@ -695,8 +696,10 @@ static void CmdLosim(char *str) c.d.asBytes[j] = GraphBuffer[i+j]; } SendCommand(&c); + wait_for_response(CMD_ACK); } + PrintToScrollback("Starting simulator..."); UsbCommand c={CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}}; SendCommand(&c); } @@ -3063,14 +3066,19 @@ void UsbCommandReceived(UsbCommand *c) /* Maybe it's a response: */ switch(current_command) { case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: - if (c->cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) goto unexpected_response; - int i; - for(i=0; i<48; i++) sample_buf[i] = c->d.asBytes[i]; - received_command = c->cmd; - return; - default: - unexpected_response: - PrintToScrollback("unrecognized command %08x\n", c->cmd); - break; + if (c->cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) goto unexpected_response; + int i; + for(i=0; i<48; i++) sample_buf[i] = c->d.asBytes[i]; + received_command = c->cmd; + return; + case CMD_DOWNLOADED_SIM_SAMPLES_125K: + if (c->cmd != CMD_ACK) goto unexpected_response; + // got ACK + received_command = c->cmd; + return; + default: + unexpected_response: + PrintToScrollback("unrecognized command %08x\n", c->cmd); + break; } }