Rework hf tune to make it synchronous (needed for rdv4)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
12
client/ui.c
12
client/ui.c
@@ -63,8 +63,6 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||
char buffer2[MAX_PRINT_BUFFER + 20] = {0};
|
||||
char *token = NULL;
|
||||
char *tmp_ptr = NULL;
|
||||
// {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG}
|
||||
static const char *prefixes[7] = { "", "[+] ", "[=] ", "[-] ", "[!] ", "[!!] ", "[#] "};
|
||||
FILE *stream = stdout;
|
||||
|
||||
switch (level) {
|
||||
@@ -88,7 +86,8 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||
strncpy(prefix, _YELLOW_("[=]"), sizeof(prefix) - 1);
|
||||
break;
|
||||
case NORMAL:
|
||||
strncpy(prefix, prefixes[level], sizeof(prefix) - 1);
|
||||
case INPLACE:
|
||||
// no prefixes for normal & inplace
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -97,11 +96,16 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||
vsnprintf(buffer, sizeof(buffer), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
// no prefixes for normal
|
||||
// no prefixes for normal & inplace
|
||||
if (level == NORMAL) {
|
||||
fPrintAndLog(stream, "%s", buffer);
|
||||
return;
|
||||
}
|
||||
if (level == INPLACE) {
|
||||
printf("%s\r", buffer);
|
||||
fflush(stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strchr(buffer, '\n')) {
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ extern session_arg_t session;
|
||||
#define M_PI 3.14159265358979323846264338327
|
||||
#endif
|
||||
#define MAX_PRINT_BUFFER 2048
|
||||
typedef enum logLevel {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG} logLevel_t;
|
||||
typedef enum logLevel {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG, INPLACE} logLevel_t;
|
||||
|
||||
void ShowGui(void);
|
||||
void HideGraphWindow(void);
|
||||
|
||||
Reference in New Issue
Block a user