int i, j, clock, header, rows, bit, hithigh, hitlow, first, bit2idx, high, low;\r
int parity[4];\r
char id[11];\r
+ int retested = 0;\r
int BitStream[MAX_GRAPH_TRACE_LEN];\r
high = low = 0;\r
\r
if (hithigh && hitlow)\r
break;\r
}\r
-\r
+ \r
/* If we didn't hit both high and low peaks, we had a bit transition */\r
if (!hithigh || !hitlow)\r
bit ^= 1;\r
-\r
+ \r
BitStream[bit2idx++] = bit;\r
}\r
-\r
+ \r
+retest:\r
/* We go till 5 before the graph ends because we'll get that far below */\r
for (i = 1; i < bit2idx - 5; i++)\r
{\r
\r
/* Stop any loops */\r
go = 0;\r
- break;\r
+ return;\r
}\r
\r
/* Crap! Incorrect parity or no stop bit, start all over */\r
header = 0;\r
}\r
}\r
+ \r
+ /* if we've already retested after flipping bits, return */\r
+ if (retested++)\r
+ return;\r
+\r
+ /* if this didn't work, try flipping bits */\r
+ for (i = 0; i < bit2idx; i++)\r
+ BitStream[i] ^= 1;\r
+\r
+ goto retest;\r
}\r
\r
/* emulate an EM410X tag\r
* - we're high: transition if we hit a low\r
* (we need to do it this way because some tags keep high or\r
* low for long periods, others just reach the peak and go\r
- * down)
+ * down)\r
*/\r
if ((GraphBuffer[i]==high) && (GraphBuffer[i-1] == c)) {\r
GraphBuffer[i]=1-c;\r