From df404a652a4a1294249400fc4b9410d555810907 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 21 Jul 2020 10:49:29 +0200 Subject: [PATCH] duration isnt 15bits, its 16. length is 15bits. --- armsrc/BigBuf.c | 17 +++++++++++++---- armsrc/BigBuf.h | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/armsrc/BigBuf.c b/armsrc/BigBuf.c index 338206d6e..608c38040 100644 --- a/armsrc/BigBuf.c +++ b/armsrc/BigBuf.c @@ -221,17 +221,17 @@ bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_ duration = (UINT32_MAX - timestamp_start) + timestamp_end; } - if (duration > 0x7FFF) { + if (duration > 0xFFFF) { /* if (DBGLEVEL >= DBG_DEBUG) { - Dbprintf("Error in LogTrace: duration too long for 15 bits encoding: 0x%08x start: 0x%08x end: 0x%08x", duration, timestamp_start, timestamp_end); + Dbprintf("Error in LogTrace: duration too long for 16 bits encoding: 0x%08x start: 0x%08x end: 0x%08x", duration, timestamp_start, timestamp_end); } */ - duration /= 32; + duration = 0; } hdr->timestamp = timestamp_start; - hdr->duration = duration & 0x7FFF; + hdr->duration = duration & 0xFFFF; hdr->data_len = iLen; hdr->isResponse = !readerToTag; trace_len += TRACELOG_HDR_LEN; @@ -254,6 +254,15 @@ bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_ return true; } +// specific LogTrace function for ISO15693: the duration needs to be scaled because otherwise it won't fit into a uint16_t +bool LogTrace_ISO15693(const uint8_t *bytes, uint16_t len, uint32_t ts_start, uint32_t ts_end, uint8_t *parity, bool reader2tag) { + uint32_t duration = ts_end - ts_start; + duration /= 32; + ts_end = ts_start + duration; + return LogTrace(bytes, len, ts_start, ts_end, parity, reader2tag); +} + + // Emulator memory uint8_t emlSet(uint8_t *data, uint32_t offset, uint32_t length) { uint8_t *mem = BigBuf_get_EM_addr(); diff --git a/armsrc/BigBuf.h b/armsrc/BigBuf.h index 2f381f36b..8b570cb8c 100644 --- a/armsrc/BigBuf.h +++ b/armsrc/BigBuf.h @@ -42,7 +42,11 @@ void clear_trace(void); void set_tracing(bool enable); void set_tracelen(uint32_t value); bool get_tracing(void); + bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_start, uint32_t timestamp_end, uint8_t *parity, bool readerToTag); +bool LogTrace_ISO15693(const uint8_t *bytes, uint16_t len, uint32_t ts_start, uint32_t ts_end, uint8_t *parity, bool reader2tag); + + uint8_t emlSet(uint8_t *data, uint32_t offset, uint32_t length);