change t55xx detect to unset lf config decimation to 1 if its value wasnt 1. Thanks to @mwalker33

This commit is contained in:
iceman1001 2021-07-28 09:51:35 +02:00
commit bc5d7084c3
2 changed files with 34 additions and 3 deletions

View file

@ -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) {

View file

@ -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;
}