X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/15db5fb71a07c6f7431ebdaff78f53df3c4fe022..f23e056d950c72582ddb1d3d68ad5d012541afff:/winsrc/command.cpp diff --git a/winsrc/command.cpp b/winsrc/command.cpp index 0397ea37..8a7fd6fb 100644 --- a/winsrc/command.cpp +++ b/winsrc/command.cpp @@ -52,6 +52,13 @@ static void CmdReset(char *str) SendCommand(&c, FALSE); } +static void CmdBuffClear(char *str) +{ + UsbCommand c; + c.cmd = CMD_BUFF_CLEAR; + SendCommand(&c, FALSE); + CmdClearGraph(TRUE); +} static void CmdQuit(char *str) { @@ -262,6 +269,7 @@ static void CmdEM410xread(char *str) int i, j, clock, header, rows, bit, hithigh, hitlow, first, bit2idx, high, low; int parity[4]; char id[11]; + int retested = 0; int BitStream[MAX_GRAPH_TRACE_LEN]; high = low = 0; @@ -307,14 +315,15 @@ static void CmdEM410xread(char *str) if (hithigh && hitlow) break; } - + /* If we didn't hit both high and low peaks, we had a bit transition */ if (!hithigh || !hitlow) bit ^= 1; - + BitStream[bit2idx++] = bit; } - + +retest: /* We go till 5 before the graph ends because we'll get that far below */ for (i = 1; i < bit2idx - 5; i++) { @@ -363,7 +372,7 @@ static void CmdEM410xread(char *str) /* Stop any loops */ go = 0; - break; + return; } /* Crap! Incorrect parity or no stop bit, start all over */ @@ -388,6 +397,16 @@ static void CmdEM410xread(char *str) header = 0; } } + + /* if we've already retested after flipping bits, return */ + if (retested++) + return; + + /* if this didn't work, try flipping bits */ + for (i = 0; i < bit2idx; i++) + BitStream[i] ^= 1; + + goto retest; } /* emulate an EM410X tag @@ -1862,7 +1881,7 @@ static void Cmdaskdemod(char *str) { * - we're high: transition if we hit a low * (we need to do it this way because some tags keep high or * low for long periods, others just reach the peak and go - * down) + * down) */ if ((GraphBuffer[i]==high) && (GraphBuffer[i-1] == c)) { GraphBuffer[i]=1-c; @@ -2384,6 +2403,7 @@ static struct { "autocorr", CmdAutoCorr,1, " -- Autocorrelation over window", "bitsamples", CmdBitsamples,0, " Get raw samples as bitstring", "bitstream", Cmdbitstream,1, "[clock rate] -- Convert waveform into a bitstream", + "buffclear", CmdBuffClear,0, " Clear sample buffer and graph window", "dec", CmdDec,1, " Decimate samples", "detectclock", Cmddetectclockrate,1, " Detect clock rate", "em410xsim", CmdEM410xsim,1, " -- Simulate EM410x tag",