From bc5d7084c34cae8fa1d3848b21953b73a76c5ec5 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 28 Jul 2021 09:51:35 +0200 Subject: [PATCH] change t55xx detect to unset lf config decimation to 1 if its value wasnt 1. Thanks to @mwalker33 --- armsrc/lfsampling.c | 4 +--- client/src/cmdlft55xx.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index ed65fcb9b..60b25436a 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -45,9 +45,7 @@ void printLFConfig(void) { Dbprintf(" [a] averaging........... %s", (config.averaging) ? "yes" : "no"); Dbprintf(" [t] trigger threshold... %d", config.trigger_threshold); Dbprintf(" [s] samples to skip..... %d ", config.samples_to_skip); - - DbpString(_CYAN_("LF Sampling Stack")); - print_stack_usage(); + DbpString(""); } void printSamples(void) { diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index 765f966e4..67818c266 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -942,6 +942,27 @@ static int CmdT55xxDetect(const char *Cmd) { // detect called so clear data blocks T55x7_ClearAllBlockData(); + // make sure decimate == 1 + sample_config curr_lf_config; + memset(&curr_lf_config, 0, sizeof(sample_config)); + + res = lf_getconfig(&curr_lf_config); + if (res != PM3_SUCCESS) { + PrintAndLogEx(ERR, "failed to get current device LF config"); + return res; + } + int8_t old_decimation = curr_lf_config.decimation; + if (curr_lf_config.decimation != 1) { + curr_lf_config.decimation = 1; + curr_lf_config.verbose = false; + res = lf_config(&curr_lf_config); + if (res != PM3_SUCCESS) { + PrintAndLogEx(ERR, "failed to set LF configuration decimation value to 1"); + return res; + } + } + + // sanity check. if (SanityOfflineCheck(use_gb) != PM3_SUCCESS) return PM3_ESOFT; @@ -1016,6 +1037,18 @@ static int CmdT55xxDetect(const char *Cmd) { config.pwd = 0x00; PrintAndLogEx(WARNING, "Could not detect modulation automatically. Try setting it manually with " _YELLOW_("\'lf t55xx config\'")); } + + + if (old_decimation != curr_lf_config.decimation) { + curr_lf_config.decimation = old_decimation; + curr_lf_config.verbose = false; + res = lf_config(&curr_lf_config); + if (res != PM3_SUCCESS) { + PrintAndLogEx(ERR, "failed to restore LF configuration"); + return res; + } + } + return PM3_SUCCESS; }