fixing iso14443b (issue #103):

fix: don't waste time to calculate parity bits. Instead add void parity bits to trace and ignore them on client side
This commit is contained in:
pwpiwi 2015-06-18 07:56:08 +02:00
commit d5875804a3
2 changed files with 6 additions and 7 deletions

View file

@ -17,7 +17,6 @@
#include "iso14443crc.h" #include "iso14443crc.h"
#define RECEIVE_SAMPLES_TIMEOUT 2000 #define RECEIVE_SAMPLES_TIMEOUT 2000
#define ISO14443B_DMA_BUFFER_SIZE 512
//============================================================================= //=============================================================================
// An ISO 14443 Type B tag. We listen for commands from the reader, using // An ISO 14443 Type B tag. We listen for commands from the reader, using
@ -768,7 +767,7 @@ static void GetSamplesFor14443bDemod(int n, bool quiet)
//Tracing //Tracing
if (tracing && Demod.len > 0) { if (tracing && Demod.len > 0) {
uint8_t parity[MAX_PARITY_SIZE]; uint8_t parity[MAX_PARITY_SIZE];
GetParity(Demod.output, Demod.len, parity); //GetParity(Demod.output, Demod.len, parity);
LogTrace(Demod.output, Demod.len, 0, 0, parity, FALSE); LogTrace(Demod.output, Demod.len, 0, 0, parity, FALSE);
} }
} }
@ -1156,7 +1155,7 @@ void RAMFUNC SnoopIso14443b(void)
if (!TagIsActive) { // no need to try decoding reader data if the tag is sending if (!TagIsActive) { // no need to try decoding reader data if the tag is sending
if(Handle14443bUartBit(ci & 0x01)) { if(Handle14443bUartBit(ci & 0x01)) {
if(triggered && tracing) { if(triggered && tracing) {
GetParity(Uart.output, Uart.byteCnt, parity); //GetParity(Uart.output, Uart.byteCnt, parity);
LogTrace(Uart.output, Uart.byteCnt, samples, samples, parity, TRUE); LogTrace(Uart.output, Uart.byteCnt, samples, samples, parity, TRUE);
} }
/* And ready to receive another command. */ /* And ready to receive another command. */
@ -1167,7 +1166,7 @@ void RAMFUNC SnoopIso14443b(void)
} }
if(Handle14443bUartBit(cq & 0x01)) { if(Handle14443bUartBit(cq & 0x01)) {
if(triggered && tracing) { if(triggered && tracing) {
GetParity(Uart.output, Uart.byteCnt, parity); //GetParity(Uart.output, Uart.byteCnt, parity);
LogTrace(Uart.output, Uart.byteCnt, samples, samples, parity, TRUE); LogTrace(Uart.output, Uart.byteCnt, samples, samples, parity, TRUE);
} }
/* And ready to receive another command. */ /* And ready to receive another command. */
@ -1186,7 +1185,7 @@ void RAMFUNC SnoopIso14443b(void)
if(tracing) if(tracing)
{ {
uint8_t parity[MAX_PARITY_SIZE]; uint8_t parity[MAX_PARITY_SIZE];
GetParity(Demod.output, Demod.len, parity); //GetParity(Demod.output, Demod.len, parity);
LogTrace(Demod.output, Demod.len, samples, samples, parity, FALSE); LogTrace(Demod.output, Demod.len, samples, samples, parity, FALSE);
} }
triggered = TRUE; triggered = TRUE;
@ -1194,7 +1193,7 @@ void RAMFUNC SnoopIso14443b(void)
// And ready to receive another response. // And ready to receive another response.
DemodReset(); DemodReset();
} }
TagIsActive = (Demod.state > DEMOD_PHASE_REF_TRAINING); TagIsActive = (Demod.state > DEMOD_GOT_FALLING_EDGE_OF_SOF);
} }
} }

View file

@ -378,7 +378,7 @@ uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, ui
oddparity ^= (((frame[j] & 0xFF) >> k) & 0x01); oddparity ^= (((frame[j] & 0xFF) >> k) & 0x01);
} }
uint8_t parityBits = parityBytes[j>>3]; uint8_t parityBits = parityBytes[j>>3];
if (isResponse && (oddparity != ((parityBits >> (7-(j&0x0007))) & 0x01))) { if (protocol != ISO_14443B && isResponse && (oddparity != ((parityBits >> (7-(j&0x0007))) & 0x01))) {
snprintf(line[j/16]+(( j % 16) * 4),110, "%02x! ", frame[j]); snprintf(line[j/16]+(( j % 16) * 4),110, "%02x! ", frame[j]);
} else { } else {