refactor continuous mode

This commit is contained in:
iceman1001 2020-10-24 11:56:47 +02:00
commit 8f954ebf9d
3 changed files with 33 additions and 39 deletions

View file

@ -311,19 +311,8 @@ int CmdHFSniff(const char *Cmd) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
int CmdHFPlot(const char *Cmd) { int handle_hf_plot(void) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf plot",
"Plots HF signal after RF signal path and A/D conversion.",
"This can be used after any hf command and will show the last few milliseconds of the HF signal.\n"
"Note: If the last hf command terminated because of a timeout you will most probably see nothing.\n");
void *argtable[] = {
arg_param_begin,
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
CLIParserFree(ctx);
uint8_t buf[FPGA_TRACE_SIZE]; uint8_t buf[FPGA_TRACE_SIZE];
PacketResponseNG response; PacketResponseNG response;
@ -333,7 +322,7 @@ int CmdHFPlot(const char *Cmd) {
} }
for (size_t i = 0; i < FPGA_TRACE_SIZE; i++) { for (size_t i = 0; i < FPGA_TRACE_SIZE; i++) {
GraphBuffer[i] = ((int)buf[i]) - 127; GraphBuffer[i] = ((int)buf[i]) - 128;
} }
GraphTraceLen = FPGA_TRACE_SIZE; GraphTraceLen = FPGA_TRACE_SIZE;
@ -349,6 +338,22 @@ int CmdHFPlot(const char *Cmd) {
return PM3_SUCCESS; return PM3_SUCCESS;
} }
int CmdHFPlot(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf plot",
"Plots HF signal after RF signal path and A/D conversion.",
"This can be used after any hf command and will show the last few milliseconds of the HF signal.\n"
"Note: If the last hf command terminated because of a timeout you will most probably see nothing.\n");
void *argtable[] = {
arg_param_begin,
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
CLIParserFree(ctx);
return handle_hf_plot();
}
static command_t CommandTable[] = { static command_t CommandTable[] = {
{"--------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("High Frequency") " -----------------------"}, {"--------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("High Frequency") " -----------------------"},

View file

@ -19,4 +19,5 @@ int CmdHFSearch(const char *Cmd);
int CmdHFSniff(const char *Cmd); int CmdHFSniff(const char *Cmd);
int CmdHFPlot(const char *Cmd); int CmdHFPlot(const char *Cmd);
int handle_hf_plot(void);
#endif #endif

View file

@ -27,10 +27,8 @@
#include "crc16.h" #include "crc16.h"
#include "util_posix.h" // msclock #include "util_posix.h" // msclock
#include "aidsearch.h" #include "aidsearch.h"
#include "proxgui.h" #include "cmdhf.h" // handle HF plot
#include "cmddata.h"
#include "graph.h"
#include "fpga.h"
bool APDUInFramingEnable = true; bool APDUInFramingEnable = true;
@ -568,35 +566,25 @@ static int CmdHF14AReader(const char *Cmd) {
} }
} }
plot: plot:
if (continuous) { if (continuous) {
uint8_t buf[FPGA_TRACE_SIZE]; res = handle_hf_plot();
if (res != PM3_SUCCESS) {
PacketResponseNG response; break;
if (!GetFromDevice(FPGA_MEM, buf, FPGA_TRACE_SIZE, 0, NULL, 0, &response, 4000, true)) {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
return PM3_ETIMEOUT;
} }
for (size_t i = 0; i < FPGA_TRACE_SIZE; i++) {
GraphBuffer[i] = ((int)buf[i]) - 127;
}
GraphTraceLen = FPGA_TRACE_SIZE;
// remove signal offset
CmdHpf("");
setClockGrid(0, 0);
DemodBufferLen = 0;
RepaintGraphWindow();
} }
if (kbd_enter_pressed()) { if (kbd_enter_pressed()) {
break; break;
} }
} while (continuous); } while (continuous);
if (disconnectAfter) { if (disconnectAfter) {
if (!silent) PrintAndLogEx(INFO, "field dropped."); if (silent == false) {
PrintAndLogEx(INFO, "field dropped.");
}
} }
if (continuous) if (continuous)
return PM3_SUCCESS; return PM3_SUCCESS;
else else