mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
Unify 'lf read' and 'lf cmdread options', add options to cmdread
This commit is contained in:
parent
7621af2e88
commit
c994323105
6 changed files with 100 additions and 48 deletions
|
@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file.
|
||||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||||
|
|
||||||
## [unreleased][unreleased]
|
## [unreleased][unreleased]
|
||||||
- Add option for continuous mode to `lf read`, try e.g. `data plot` then `lf read d 3000 s c` (@doegox)
|
- Add options to `lf read` and `lf cmdread` (@doegox)
|
||||||
|
- Change options of `lf read` to match `lf cmdread`, this affects historical `d` and `s` options (@doegox)
|
||||||
- Add `hf waveshare` to upload picture to Waveshare NFC-Powered e-Paper (@doegox)
|
- Add `hf waveshare` to upload picture to Waveshare NFC-Powered e-Paper (@doegox)
|
||||||
- Add `hf 14a config` to deal with badly configured cards: invalid ATQA/BCC/SAK (@doegox)
|
- Add `hf 14a config` to deal with badly configured cards: invalid ATQA/BCC/SAK (@doegox)
|
||||||
- Mikron JSC Russia Ultralight EV1 41 pages tag type support (@McEloff)
|
- Mikron JSC Russia Ultralight EV1 41 pages tag type support (@McEloff)
|
||||||
|
|
|
@ -759,8 +759,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
}
|
}
|
||||||
case CMD_LF_ACQ_RAW_ADC: {
|
case CMD_LF_ACQ_RAW_ADC: {
|
||||||
struct p {
|
struct p {
|
||||||
bool verbose;
|
uint32_t samples : 31;
|
||||||
uint32_t samples;
|
bool verbose : 1;
|
||||||
} PACKED;
|
} PACKED;
|
||||||
struct p *payload = (struct p *)packet->data.asBytes;
|
struct p *payload = (struct p *)packet->data.asBytes;
|
||||||
uint32_t bits = SampleLF(payload->verbose, payload->samples);
|
uint32_t bits = SampleLF(payload->verbose, payload->samples);
|
||||||
|
@ -772,9 +772,11 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
uint32_t delay;
|
uint32_t delay;
|
||||||
uint16_t ones;
|
uint16_t ones;
|
||||||
uint16_t zeros;
|
uint16_t zeros;
|
||||||
|
uint32_t samples : 31;
|
||||||
|
bool verbose : 1;
|
||||||
} PACKED;
|
} PACKED;
|
||||||
struct p *payload = (struct p *)packet->data.asBytes;
|
struct p *payload = (struct p *)packet->data.asBytes;
|
||||||
ModThenAcquireRawAdcSamples125k(payload->delay, payload->zeros, payload->ones, packet->data.asBytes + 8);
|
ModThenAcquireRawAdcSamples125k(payload->delay, payload->zeros, payload->ones, packet->data.asBytes + sizeof(struct p), payload->verbose, payload->samples);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_LF_SNIFF_RAW_ADC: {
|
case CMD_LF_SNIFF_RAW_ADC: {
|
||||||
|
|
|
@ -383,7 +383,7 @@ void loadT55xxConfig(void) {
|
||||||
* @param period_1
|
* @param period_1
|
||||||
* @param command (in binary char array)
|
* @param command (in binary char array)
|
||||||
*/
|
*/
|
||||||
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint32_t period_1, uint8_t *command) {
|
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint32_t period_1, uint8_t *command, bool verbose, uint32_t samples) {
|
||||||
|
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER | FPGA_LF_ADC_READER_FIELD);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER | FPGA_LF_ADC_READER_FIELD);
|
||||||
|
|
||||||
// now do the read
|
// now do the read
|
||||||
DoAcquisition_config(true, 0);
|
DoAcquisition_config(verbose, samples);
|
||||||
|
|
||||||
// Turn off antenna
|
// Turn off antenna
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
|
|
||||||
#include "pm3_cmd.h" // struct
|
#include "pm3_cmd.h" // struct
|
||||||
|
|
||||||
void AcquireRawAdcSamples125k(int divisor);
|
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint32_t period_1, uint8_t *command, bool verbose, uint32_t samples);
|
||||||
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint32_t period_1, uint8_t *command);
|
|
||||||
void ReadTItag(void);
|
void ReadTItag(void);
|
||||||
void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc);
|
void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc);
|
||||||
|
|
||||||
|
|
|
@ -329,7 +329,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, in
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
if (checked == -1) {
|
if (checked == -1) {
|
||||||
Dbprintf("lf sampling aborted");
|
Dbprintf("lf sampling aborted");
|
||||||
} else if (cancel_counter == cancel_after) {
|
} else if ((cancel_counter == cancel_after) && (cancel_after > 0)){
|
||||||
Dbprintf("lf sampling cancelled after %u", cancel_counter);
|
Dbprintf("lf sampling cancelled after %u", cancel_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,33 +61,43 @@ static bool g_lf_threshold_set = false;
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
static int usage_lf_cmdread(void) {
|
static int usage_lf_cmdread(void) {
|
||||||
PrintAndLogEx(NORMAL, "Usage: lf cmdread d <delay period> z <zero period> o <one period> c <cmdbytes>");
|
PrintAndLogEx(NORMAL, "Usage: lf cmdread d <delay period> z <zero period> o <one period> c <cmdbytes> [q] [s #samples] [@]");
|
||||||
PrintAndLogEx(NORMAL, "Options:");
|
PrintAndLogEx(NORMAL, "Options:");
|
||||||
PrintAndLogEx(NORMAL, " h This help");
|
PrintAndLogEx(NORMAL, " h This help");
|
||||||
PrintAndLogEx(NORMAL, " d <delay> delay OFF period, (0 for bitbang mode) (decimal)");
|
PrintAndLogEx(NORMAL, " d <delay> delay OFF period, (0 for bitbang mode) (decimal)");
|
||||||
PrintAndLogEx(NORMAL, " z <zero> ZERO time period (decimal)");
|
PrintAndLogEx(NORMAL, " z <zero> ZERO time period (decimal)");
|
||||||
PrintAndLogEx(NORMAL, " o <one> ONE time period (decimal)");
|
PrintAndLogEx(NORMAL, " o <one> ONE time period (decimal)");
|
||||||
PrintAndLogEx(NORMAL, " c <cmd> Command bytes (in ones and zeros)");
|
PrintAndLogEx(NORMAL, " c <cmd> Command bytes (in ones and zeros)");
|
||||||
|
PrintAndLogEx(NORMAL, " q silent (optional)");
|
||||||
|
PrintAndLogEx(NORMAL, " s #samples number of samples to collect (optional)");
|
||||||
|
PrintAndLogEx(NORMAL, " @ run continuously until a key is pressed (optional)");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, " ************* " _YELLOW_("All periods in microseconds (us)"));
|
PrintAndLogEx(NORMAL, " ************* " _YELLOW_("All periods in microseconds (us)"));
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
PrintAndLogEx(NORMAL, "Examples:");
|
||||||
PrintAndLogEx(NORMAL, " lf cmdread d 80 z 100 o 200 c 11000");
|
PrintAndLogEx(NORMAL, "- probing for HT2:");
|
||||||
|
PrintAndLogEx(NORMAL, " lf cmdread d 50 z 116 o 166 c 011000");
|
||||||
|
PrintAndLogEx(NORMAL, "- probing for HT2, oscilloscope style:");
|
||||||
|
PrintAndLogEx(NORMAL, " data plot");
|
||||||
|
PrintAndLogEx(NORMAL, " lf cmdread d 50 z 116 o 166 c 011000 q s 2000 @");
|
||||||
PrintAndLogEx(NORMAL, "Extras:");
|
PrintAndLogEx(NORMAL, "Extras:");
|
||||||
PrintAndLogEx(NORMAL, " use " _YELLOW_("'lf config'")" to set parameters.");
|
PrintAndLogEx(NORMAL, " use " _YELLOW_("'lf config'")" to set parameters.");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
static int usage_lf_read(void) {
|
static int usage_lf_read(void) {
|
||||||
PrintAndLogEx(NORMAL, "Usage: lf read [h] [s] [d numofsamples] [c]");
|
PrintAndLogEx(NORMAL, "Usage: lf read [h] [q] [s #samples] [@]");
|
||||||
PrintAndLogEx(NORMAL, "Options:");
|
PrintAndLogEx(NORMAL, "Options:");
|
||||||
PrintAndLogEx(NORMAL, " h This help");
|
PrintAndLogEx(NORMAL, " h This help");
|
||||||
PrintAndLogEx(NORMAL, " d #samples # samples to collect (optional)");
|
PrintAndLogEx(NORMAL, " q silent (optional)");
|
||||||
PrintAndLogEx(NORMAL, " s silent");
|
PrintAndLogEx(NORMAL, " s #samples number of samples to collect (optional)");
|
||||||
PrintAndLogEx(NORMAL, " c run continuously until a key is pressed");
|
PrintAndLogEx(NORMAL, " @ run continuously until a key is pressed (optional)");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
PrintAndLogEx(NORMAL, "Examples:");
|
||||||
PrintAndLogEx(NORMAL, " lf read s d 12000 - collects 12000 samples silent");
|
|
||||||
PrintAndLogEx(NORMAL, " lf read d 3000 s c - to be used with 'data plot' for live oscillo style");
|
|
||||||
PrintAndLogEx(NORMAL, " lf read");
|
PrintAndLogEx(NORMAL, " lf read");
|
||||||
|
PrintAndLogEx(NORMAL, "- collecting quietly 12000 samples:");
|
||||||
|
PrintAndLogEx(NORMAL, " lf read q s 12000 - ");
|
||||||
|
PrintAndLogEx(NORMAL, "- oscilloscope style:");
|
||||||
|
PrintAndLogEx(NORMAL, " data plot");
|
||||||
|
PrintAndLogEx(NORMAL, " lf read q s 3000 @");
|
||||||
PrintAndLogEx(NORMAL, "Extras:");
|
PrintAndLogEx(NORMAL, "Extras:");
|
||||||
PrintAndLogEx(NORMAL, " use " _YELLOW_("'lf config'")" to set parameters.");
|
PrintAndLogEx(NORMAL, " use " _YELLOW_("'lf config'")" to set parameters.");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -309,14 +319,22 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||||
if (!session.pm3_present) return PM3_ENOTTY;
|
if (!session.pm3_present) return PM3_ENOTTY;
|
||||||
|
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
|
bool verbose = true;
|
||||||
|
bool continuous = false;
|
||||||
|
uint32_t samples = 0;
|
||||||
uint16_t datalen = 0;
|
uint16_t datalen = 0;
|
||||||
|
|
||||||
|
uint8_t payload_header_size = 12;
|
||||||
struct p {
|
struct p {
|
||||||
uint32_t delay;
|
uint32_t delay;
|
||||||
uint16_t ones;
|
uint16_t ones;
|
||||||
uint16_t zeros;
|
uint16_t zeros;
|
||||||
uint8_t data[PM3_CMD_DATA_SIZE - 8];
|
uint32_t samples : 31;
|
||||||
|
bool verbose : 1;
|
||||||
|
uint8_t data[PM3_CMD_DATA_SIZE - payload_header_size];
|
||||||
} PACKED payload;
|
} PACKED payload;
|
||||||
|
payload.samples = samples;
|
||||||
|
payload.verbose = verbose;
|
||||||
|
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
|
@ -339,6 +357,20 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||||
payload.ones = param_get32ex(Cmd, cmdp + 1, 0, 10) & 0xFFFF;
|
payload.ones = param_get32ex(Cmd, cmdp + 1, 0, 10) & 0xFFFF;
|
||||||
cmdp += 2;
|
cmdp += 2;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
samples = param_get32ex(Cmd, cmdp + 1, 0, 10);
|
||||||
|
payload.samples = samples;
|
||||||
|
cmdp += 2;
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
verbose = false;
|
||||||
|
payload.verbose = verbose;
|
||||||
|
cmdp++;
|
||||||
|
break;
|
||||||
|
case '@':
|
||||||
|
continuous = true;
|
||||||
|
cmdp++;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||||
errors = true;
|
errors = true;
|
||||||
|
@ -356,34 +388,52 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||||
|
|
||||||
//Validations
|
//Validations
|
||||||
if (errors || cmdp == 0) return usage_lf_cmdread();
|
if (errors || cmdp == 0) return usage_lf_cmdread();
|
||||||
|
if (continuous) {
|
||||||
|
PrintAndLogEx(INFO, "Press " _GREEN_("Enter") " to exit");
|
||||||
|
}
|
||||||
|
if (verbose) {
|
||||||
|
PrintAndLogEx(SUCCESS, "Sending command...");
|
||||||
|
}
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "sending");
|
int ret = PM3_SUCCESS;
|
||||||
|
do {
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_LF_MOD_THEN_ACQ_RAW_ADC, (uint8_t *)&payload, 8 + datalen);
|
SendCommandNG(CMD_LF_MOD_THEN_ACQ_RAW_ADC, (uint8_t *)&payload, payload_header_size + datalen);
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
|
|
||||||
uint8_t i = 10;
|
uint8_t i = 10;
|
||||||
// 20sec wait loop
|
// 20sec wait loop
|
||||||
while (!WaitForResponseTimeout(CMD_LF_MOD_THEN_ACQ_RAW_ADC, &resp, 2000) && i != 0) {
|
while (!WaitForResponseTimeout(CMD_LF_MOD_THEN_ACQ_RAW_ADC, &resp, 2000) && i != 0) {
|
||||||
|
if (verbose) {
|
||||||
PrintAndLogEx(NORMAL, "." NOLF);
|
PrintAndLogEx(NORMAL, "." NOLF);
|
||||||
|
}
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
if (verbose) {
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
}
|
||||||
if (resp.status == PM3_SUCCESS) {
|
if (resp.status == PM3_SUCCESS) {
|
||||||
if (i) {
|
if (i) {
|
||||||
|
if (verbose) {
|
||||||
PrintAndLogEx(SUCCESS, "downloading response signal data");
|
PrintAndLogEx(SUCCESS, "downloading response signal data");
|
||||||
getSamples(0, false);
|
}
|
||||||
return PM3_SUCCESS;
|
getSamples(samples, false);
|
||||||
|
ret = PM3_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
PrintAndLogEx(WARNING, "command failed.");
|
PrintAndLogEx(WARNING, "command failed.");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
if (kbd_enter_pressed()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (continuous);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int CmdFlexdemod(const char *Cmd) {
|
int CmdFlexdemod(const char *Cmd) {
|
||||||
(void)Cmd; // Cmd is not used so far
|
(void)Cmd; // Cmd is not used so far
|
||||||
|
@ -597,8 +647,8 @@ int lf_read(bool verbose, uint32_t samples) {
|
||||||
if (!session.pm3_present) return PM3_ENOTTY;
|
if (!session.pm3_present) return PM3_ENOTTY;
|
||||||
|
|
||||||
struct p {
|
struct p {
|
||||||
bool verbose;
|
uint32_t samples : 31;
|
||||||
uint32_t samples;
|
bool verbose : 1;
|
||||||
} PACKED;
|
} PACKED;
|
||||||
|
|
||||||
struct p payload;
|
struct p payload;
|
||||||
|
@ -636,15 +686,15 @@ int CmdLFRead(const char *Cmd) {
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||||
case 'h':
|
case 'h':
|
||||||
return usage_lf_read();
|
return usage_lf_read();
|
||||||
case 'd':
|
case 's':
|
||||||
samples = param_get32ex(Cmd, cmdp + 1, 0, 10);
|
samples = param_get32ex(Cmd, cmdp + 1, 0, 10);
|
||||||
cmdp += 2;
|
cmdp += 2;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 'q':
|
||||||
verbose = false;
|
verbose = false;
|
||||||
cmdp++;
|
cmdp++;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case '@':
|
||||||
continuous = true;
|
continuous = true;
|
||||||
cmdp++;
|
cmdp++;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue