From: skamkar Date: Fri, 3 Jul 2009 00:56:12 +0000 (+0000) Subject: with em410xread, retest if we read our bits the wrong way (1=0 and 0=1) X-Git-Tag: v1.0.0~591 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/a91ff4c8e7d5f2736485525c22ad70a7bf4722af?ds=sidebyside with em410xread, retest if we read our bits the wrong way (1=0 and 0=1) --- diff --git a/winsrc/command.cpp b/winsrc/command.cpp index 0397ea37..8da91f52 100644 --- a/winsrc/command.cpp +++ b/winsrc/command.cpp @@ -262,6 +262,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 +308,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 +365,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 +390,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 +1874,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;