From 5604afce7a3d5e116ac0994f7dc2cb1887eb2328 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 19 Apr 2021 22:18:37 +0200 Subject: [PATCH] trace list - now colors whole reader line output. Also little nasty buff-underflow bug fixed --- CHANGELOG.md | 2 ++ client/src/cmdtrace.c | 84 ++++++++++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7a2dd375..327ac9f61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] + - Change `hf 14a/14b/15 list etc alias commands now unified helptext (@doegox) + - Change `trace list` - now colors whole reader line (@iceman1001) - Change `lf search` - add option `-c` to continue searching after first hit (@doegox) - Fix DESFire mis-annotation (@VortixDev) - Change `lf pac demod` - now also search for inverted bitstreams (@iceman1001) diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index e3b371c57..4db44fb16 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -308,9 +308,12 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr } m--; } - line[(data_len - 1) / 16][((data_len - 1) % 16) * 4 + 2] = '('; - line[(data_len - 1) / 16][((data_len - 1) % 16) * 4 + 3] = m + 0x30; - line[(data_len - 1) / 16][((data_len - 1) % 16) * 4 + 4] = ')'; + + if (data_len) { + line[(data_len - 1) / 16][((data_len - 1) % 16) * 4 + 2] = '('; + line[(data_len - 1) / 16][((data_len - 1) % 16) * 4 + 3] = m + 0x30; + line[(data_len - 1) / 16][((data_len - 1) % 16) * 4 + 4] = ')'; + } } } @@ -400,32 +403,63 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr time2 = duration; } - if (use_us) { - PrintAndLogEx(NORMAL, " %10.1f | %10.1f | %s |%-72s | %s| %s", - (float)time1 / 13.56, - (float)time2 / 13.56, - (hdr->isResponse ? "Tag" : _YELLOW_("Rdr")), - line[j], - (j == num_lines - 1) ? crc : " ", - (j == num_lines - 1) ? explanation : "" - ); + if (hdr->isResponse) { + // tag row + if (use_us) { + PrintAndLogEx(NORMAL, " %10.1f | %10.1f | Tag |%-72s | %s| %s", + (float)time1 / 13.56, + (float)time2 / 13.56, + line[j], + (j == num_lines - 1) ? crc : " ", + (j == num_lines - 1) ? explanation : "" + ); + } else { + PrintAndLogEx(NORMAL, " %10u | %10u | Tag |%-72s | %s| %s", + (hdr->timestamp - first_hdr->timestamp), + (end_of_transmission_timestamp - first_hdr->timestamp), + line[j], + (j == num_lines - 1) ? crc : " ", + (j == num_lines - 1) ? explanation : "" + ); + } } else { - PrintAndLogEx(NORMAL, " %10u | %10u | %s |%-72s | %s| %s", - (hdr->timestamp - first_hdr->timestamp), - (end_of_transmission_timestamp - first_hdr->timestamp), - (hdr->isResponse ? "Tag" : _YELLOW_("Rdr")), - line[j], - (j == num_lines - 1) ? crc : " ", - (j == num_lines - 1) ? explanation : "" - ); + // reader row + if (use_us) { + PrintAndLogEx(NORMAL, + _YELLOW_(" %10.1f") " | " _YELLOW_("%10.1f") " | " _YELLOW_("Rdr") " |" _YELLOW_("%-72s")" | " _YELLOW_("%s") "| " _YELLOW_("%s"), + (float)time1 / 13.56, + (float)time2 / 13.56, + line[j], + (j == num_lines - 1) ? crc : " ", + (j == num_lines - 1) ? explanation : "" + ); + } else { + PrintAndLogEx(NORMAL, + _YELLOW_(" %10u") " | " _YELLOW_("%10u") " | " _YELLOW_("Rdr") " |" _YELLOW_("%-72s")" | " _YELLOW_("%s") "| " _YELLOW_("%s"), + (hdr->timestamp - first_hdr->timestamp), + (end_of_transmission_timestamp - first_hdr->timestamp), + line[j], + (j == num_lines - 1) ? crc : " ", + (j == num_lines - 1) ? explanation : "" + ); + } + } } else { - PrintAndLogEx(NORMAL, " | | |%-72s | %s| %s", - line[j], - (j == num_lines - 1) ? crc : " ", - (j == num_lines - 1) ? explanation : "" - ); + if (hdr->isResponse) { + PrintAndLogEx(NORMAL, " | | |%-72s | %s| %s", + line[j], + (j == num_lines - 1) ? crc : " ", + (j == num_lines - 1) ? explanation : "" + ); + } else { + PrintAndLogEx(NORMAL, " | | |" _YELLOW_("%-72s")" | " _YELLOW_("%s") "| " _YELLOW_("%s"), + line[j], + (j == num_lines - 1) ? crc : " ", + (j == num_lines - 1) ? explanation : "" + ); + } } }