From 0d0b651246b0fc68b8d33f6800a960de5547cdf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Dr=C3=B6scher?= Date: Wed, 8 Aug 2018 15:40:49 +0200 Subject: [PATCH] change: re-added trace log --- armsrc/legicrf.c | 25 ++++++++++++++++++++++++- client/cmdtrace.c | 4 ++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/armsrc/legicrf.c b/armsrc/legicrf.c index f2e80eee2..209c757b3 100644 --- a/armsrc/legicrf.c +++ b/armsrc/legicrf.c @@ -151,6 +151,9 @@ static void tx_frame(uint32_t frame, uint8_t len) { last_frame_end += RWD_FRAME_WAIT; while(GET_TICKS < last_frame_end) { }; + // backup ts for trace log + uint32_t last_frame_start = last_frame_end; + // transmit frame, MSB first for(uint8_t i = 0; i < len; ++i) { bool bit = (frame >> i) & 0x01; @@ -163,6 +166,10 @@ static void tx_frame(uint32_t frame, uint8_t len) { last_frame_end += RWD_TIME_PAUSE; while(GET_TICKS < last_frame_end) { }; HIGH(GPIO_SSC_DOUT); + + // log + uint8_t cmdbytes[] = {len, BYTEx(frame, 0), BYTEx(frame, 1), BYTEx(frame, 2)}; + LogTrace(cmdbytes, sizeof(cmdbytes), last_frame_start, last_frame_end, NULL, true); } static uint32_t rx_frame(uint8_t len) { @@ -174,6 +181,9 @@ static uint32_t rx_frame(uint8_t len) { last_frame_end += TAG_FRAME_WAIT; while(GET_TICKS < last_frame_end) { }; + // backup ts for trace log + uint32_t last_frame_start = last_frame_end; + uint32_t frame = 0; for(uint8_t i = 0; i < len; i++) { frame |= (rx_bit() ^ legic_prng_get_bit()) << i; @@ -184,6 +194,10 @@ static uint32_t rx_frame(uint8_t len) { while(GET_TICKS < last_frame_end) { }; } + // log + uint8_t cmdbytes[] = {len, BYTEx(frame, 0), BYTEx(frame, 1)}; + LogTrace(cmdbytes, sizeof(cmdbytes), last_frame_start, last_frame_end, NULL, false); + return frame; } @@ -197,6 +211,9 @@ static bool rx_ack() { last_frame_end += TAG_FRAME_WAIT; while(GET_TICKS < last_frame_end) { }; + // backup ts for trace log + uint32_t last_frame_start = last_frame_end; + uint32_t ack = 0; for(uint8_t i = 0; i < TAG_WRITE_TIMEOUT; ++i) { // sample bit @@ -213,6 +230,10 @@ static bool rx_ack() { } } + // log + uint8_t cmdbytes[] = {1, BYTEx(ack, 0)}; + LogTrace(cmdbytes, sizeof(cmdbytes), last_frame_start, last_frame_end, NULL, false); + return ack; } @@ -293,6 +314,8 @@ static uint32_t setup_phase_reader(uint8_t iv) { last_frame_end = GET_TICKS; // Switch on carrier and let the card charge for 5ms. + last_frame_end += 7500; + // Use the time to calibrate the treshhold. input_threshold = 8; // heuristically determined do { @@ -300,7 +323,7 @@ static uint32_t setup_phase_reader(uint8_t iv) { if(sample > input_threshold) { input_threshold = sample; } - } while(GET_TICKS < last_frame_end + 7500); + } while(GET_TICKS < last_frame_end); // Set threshold to noise floor * 2 input_threshold <<= 1; diff --git a/client/cmdtrace.c b/client/cmdtrace.c index 8e5a439c9..f0b27bc0f 100644 --- a/client/cmdtrace.c +++ b/client/cmdtrace.c @@ -518,9 +518,9 @@ int CmdTraceList(const char *Cmd) { if ( protocol == ISO_14443A || protocol == PROTO_MIFARE) PrintAndLogEx(NORMAL, "iso14443a - All times are in carrier periods (1/13.56Mhz)"); if ( protocol == ICLASS ) - PrintAndLogEx(NORMAL, "iClass - Timings are not as accurate"); + PrintAndLogEx(NORMAL, "iClass - Timings are not as accurate"); if ( protocol == LEGIC ) - PrintAndLogEx(NORMAL, "LEGIC - Timings are in ticks (1us == 1.5ticks)"); + PrintAndLogEx(NORMAL, "LEGIC - Timings are in ticks (1us == 1.5ticks)"); if ( protocol == ISO_15693 ) PrintAndLogEx(NORMAL, "ISO15693 - Timings are not as accurate"); if ( protocol == FELICA )