From 14a6bc3c74e2eda48ec327fe7ab98bf997507e01 Mon Sep 17 00:00:00 2001 From: chenzitai Date: Tue, 17 Jul 2018 05:01:35 +0100 Subject: [PATCH] Fix bug, card traffic is not right when using logmode=memory Print log after a round finished Otherwise it will take too much cpu cycles then the card traffic sniffing may not start in time (cherry picked from commit 48c89f5) --- Firmware/Chameleon-Mini/Codec/SniffISO14443-2A.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Firmware/Chameleon-Mini/Codec/SniffISO14443-2A.c b/Firmware/Chameleon-Mini/Codec/SniffISO14443-2A.c index 6d4b996..feb110c 100644 --- a/Firmware/Chameleon-Mini/Codec/SniffISO14443-2A.c +++ b/Firmware/Chameleon-Mini/Codec/SniffISO14443-2A.c @@ -43,6 +43,7 @@ enum RCTraffic TrafficSource; static volatile struct { volatile bool DemodFinished; volatile bool RxDone; + } Flags = { 0 }; static volatile uint16_t RxPendingSince; @@ -453,12 +454,9 @@ void Sniff14443ACodecTask(void) /* Reception finished. Process the received bytes */ if (DemodBitCount >= ISO14443A_MIN_BITS_PER_FRAME) { - // For logging data - LogEntry(LOG_INFO_CODEC_SNI_READER_DATA, CodecBuffer, (DemodBitCount+7)/8); LEDHook(LED_CODEC_RX, LED_PULSE); TrafficSource = TRAFFIC_CARD; - return; } // Get nothing, Start sniff again @@ -516,6 +514,10 @@ void Sniff14443ACodecTask(void) // BitCount = removeParityBits(CodecBuffer, BitCount); LEDHook(LED_CODEC_RX, LED_PULSE); + // Print log after a round finished + // Otherwise it will take too much cpu cycles + // then the card traffic sniffing may not start in time + LogEntry(LOG_INFO_CODEC_SNI_READER_DATA, CodecBuffer, (DemodBitCount+7)/8); LogEntry(LOG_INFO_CODEC_SNI_CARD_DATA_W_PARITY, CodecBuffer2, (BitCount + 7) / 8); // Disable card sniffing and enable reader sniffing @@ -537,6 +539,10 @@ void Sniff14443ACodecTask(void) // Reset to reader sniffing if ((SYSTICK_DIFF(RxPendingSince) > Reader_FWT + 1) ) { Flags.RxDone = true; + + // If Card sniffing started but no data get + // Then the codec must have sniffed some reader raffic + LogEntry(LOG_INFO_CODEC_SNI_READER_DATA, CodecBuffer, (DemodBitCount+7)/8); // Disable card sniffing and enable reader sniffing CardSniffDeinit(); TrafficSource = TRAFFIC_READER;