chg: 'hf sniff' - remake to mallc and report back size, also use NG
This commit is contained in:
@@ -241,15 +241,59 @@ int CmdHFTune(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// Collects pars of u8,
|
||||
// uses 16bit transfers from FPGA for speed
|
||||
// Takes all available bigbuff memory
|
||||
// data sample to download? Not sure what we can do with the data.
|
||||
int CmdHFSniff(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_hf_sniff();
|
||||
|
||||
int skippairs = param_get32ex(Cmd, 0, 0, 10);
|
||||
int skiptriggers = param_get32ex(Cmd, 1, 0, 10);
|
||||
struct {
|
||||
uint32_t samplesToSkip;
|
||||
uint32_t triggersToSkip;
|
||||
} PACKED params;
|
||||
|
||||
params.samplesToSkip = param_get32ex(Cmd, 0, 0, 10);
|
||||
params.triggersToSkip = param_get32ex(Cmd, 1, 0, 10);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_SNIFF, skippairs, skiptriggers, 0, NULL, 0);
|
||||
SendCommandNG(CMD_HF_SNIFF, (uint8_t*)¶ms, sizeof(params));
|
||||
|
||||
for (;;) {
|
||||
|
||||
if (kbd_enter_pressed()) {
|
||||
PrintAndLogEx(INFO, "User aborted");
|
||||
break;
|
||||
}
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_HF_SNIFF, &resp, 4000)) {
|
||||
|
||||
if (resp.status == PM3_EOPABORTED) {
|
||||
break;
|
||||
}
|
||||
if (resp.status == PM3_SUCCESS) {
|
||||
|
||||
uint16_t len = resp.data.asDwords[0] & 0xFFFF;
|
||||
PrintAndLogEx(INFO, "HF sniff len %u bytes", len);
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data plot") "` to view");
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data save") "` to save");
|
||||
|
||||
// download bigbuf_malloced..
|
||||
// it reservs mem from the higher range. ie we can't start from beginning idx 0.
|
||||
// but from
|
||||
uint32_t start = pm3_capabilities.bigbuf_size - len;
|
||||
int res = getSamplesEx(start, start + len, false);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "failed to download samples to client");
|
||||
return res;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(INFO, "Done.");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user