- int corr0 = 0, corr1 = 0, corrEOF = 0;
- for (j = 0; j < arraylen(Logic0); j += skip) {
- corr0 += Logic0[j] * GraphBuffer[i + (j / skip)];
- }
- for (j = 0; j < arraylen(Logic1); j += skip) {
- corr1 += Logic1[j] * GraphBuffer[i + (j / skip)];
- }
- for (j = 0; j < arraylen(FrameEOF); j += skip) {
- corrEOF += FrameEOF[j] * GraphBuffer[i + (j / skip)];
- }
- // Even things out by the length of the target waveform.
- corr0 *= 4;
- corr1 *= 4;
-
- if (corrEOF > corr1 && corrEOF > corr0) {
- PrintAndLog("EOF at %d", i);
- break;
+ int corr0 = 0, corr00 = 0, corr01 = 0, corr1 = 0, corrEOF = 0;
+ for(j = 0; j < arraylen(Logic0); j += skip) {
+ corr0 += Logic0[j]*GraphBuffer[i+(j/skip)];
+ }
+ corr01 = corr00 = corr0;
+ for(j = 0; j < arraylen(Logic0); j += skip) {
+ corr00 += Logic0[j]*GraphBuffer[i+arraylen(Logic0)/skip+(j/skip)];
+ corr01 += Logic1[j]*GraphBuffer[i+arraylen(Logic0)/skip+(j/skip)];
+ }
+ for(j = 0; j < arraylen(Logic1); j += skip) {
+ corr1 += Logic1[j]*GraphBuffer[i+(j/skip)];
+ }
+ for(j = 0; j < arraylen(FrameEOF); j += skip) {
+ corrEOF += FrameEOF[j]*GraphBuffer[i+(j/skip)];
+ }
+ // Even things out by the length of the target waveform.
+ corr00 *= 2;
+ corr01 *= 2;
+ corr0 *= 4;
+ corr1 *= 4;
+
+ if(corrEOF > corr1 && corrEOF > corr00 && corrEOF > corr01) {
+ PrintAndLog("EOF at %d", i);
+ break;