mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
Rework hf tune to make it synchronous (needed for rdv4)
This commit is contained in:
parent
995d782bb0
commit
7ed7a9de40
5 changed files with 74 additions and 34 deletions
|
@ -20,6 +20,7 @@ static int usage_hf_search() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usage_hf_sniff() {
|
||||
PrintAndLogEx(NORMAL, "The high frequence sniffer will assign all available memory on device for sniffed data");
|
||||
PrintAndLogEx(NORMAL, "Use " _YELLOW_("'data samples'")" command to download from device, and " _YELLOW_("'data plot'")" to look at it");
|
||||
|
@ -36,6 +37,16 @@ static int usage_hf_sniff() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int usage_hf_tune() {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf tune [<iter>]");
|
||||
PrintAndLogEx(NORMAL, "Continuously measure HF antenna tuning.");
|
||||
PrintAndLogEx(NORMAL, "Press button to interrupt.");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " <iter> - number of iterations (default: infinite)");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHFSearch(const char *Cmd) {
|
||||
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
|
@ -82,17 +93,35 @@ int CmdHFSearch(const char *Cmd) {
|
|||
}
|
||||
|
||||
int CmdHFTune(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
PrintAndLogEx(SUCCESS, "Measuring HF antenna, press button to exit");
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF, NULL, 0);
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_hf_tune();
|
||||
int iter = param_get32ex(Cmd, 0, 0, 10);
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING_HF, &resp, 1000)) {
|
||||
PrintAndLogEx(SUCCESS, "Measuring HF antenna, click button to exit");
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF_START, NULL, 0);
|
||||
if (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING_HF_START, &resp, 1000)) {
|
||||
PrintAndLogEx(WARNING, "Timeout while waiting for Proxmark HF measure, aborting");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
if (resp.status != PM3_EOPABORTED)
|
||||
return resp.status;
|
||||
for (uint8_t i=0; iter == 0 || i< iter; i++) { // loop forever (till button pressed) if iter = 0 (default)
|
||||
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF_SAMPLE, NULL, 0);
|
||||
if (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING_HF_SAMPLE, &resp, 1000)) {
|
||||
PrintAndLogEx(WARNING, "Timeout while waiting for Proxmark HF measure, aborting");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
if (resp.status == PM3_EOPABORTED)
|
||||
break;
|
||||
uint16_t volt = resp.data.asDwords[0];
|
||||
PrintAndLogEx(INPLACE, "%u mV / %5u V", volt, (uint16_t)(volt / 1000));
|
||||
}
|
||||
SendCommandNG(CMD_MEASURE_ANTENNA_TUNING_HF_STOP, NULL, 0);
|
||||
if (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING_HF_STOP, &resp, 1000)) {
|
||||
PrintAndLogEx(WARNING, "Timeout while waiting for Proxmark HF measure, aborting");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "Done.");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue