lf cmdread: add -k to keep field on

This commit is contained in:
Philippe Teuwen 2021-12-18 00:42:06 +01:00
commit c3864a0ce5
5 changed files with 26 additions and 14 deletions

View file

@ -3,6 +3,7 @@ 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...
## [unreleased][unreleased]
- Added option `-k` to `lf cmdread` to keep field on (@doegox)
- Added `hf mf acl` - decode and print MIFARE access rights (@iceman1001)
- Added for readline, <tab> autocomplete work inside pm3 client (@iceman1001)
- Fixed `hf iclass dump` - now uses the right key when suppling credit key (@iceman1001)

View file

@ -823,7 +823,8 @@ static void PacketReceived(PacketCommandNG *packet) {
uint16_t period_1;
uint8_t symbol_extra[LF_CMDREAD_MAX_EXTRA_SYMBOLS];
uint16_t period_extra[LF_CMDREAD_MAX_EXTRA_SYMBOLS];
uint32_t samples : 31;
uint32_t samples : 30;
bool keep : 1;
bool verbose : 1;
} PACKED;
struct p *payload = (struct p *)packet->data.asBytes;
@ -831,7 +832,7 @@ static void PacketReceived(PacketCommandNG *packet) {
uint16_t period_extra[LF_CMDREAD_MAX_EXTRA_SYMBOLS];
memcpy(symbol_extra, payload->symbol_extra, sizeof(symbol_extra));
memcpy(period_extra, payload->period_extra, sizeof(period_extra));
ModThenAcquireRawAdcSamples125k(payload->delay, payload->period_0, payload->period_1, symbol_extra, period_extra, packet->data.asBytes + sizeof(struct p), payload->verbose, payload->samples, true);
ModThenAcquireRawAdcSamples125k(payload->delay, payload->period_0, payload->period_1, symbol_extra, period_extra, packet->data.asBytes + sizeof(struct p), payload->verbose, payload->keep, payload->samples, true);
break;
}
case CMD_LF_SNIFF_RAW_ADC: {

View file

@ -383,6 +383,8 @@ void loadT55xxConfig(void) {
#endif
}
static bool prev_keep = false;
/**
* Function to do a modulation and then get samples.
* @param delay_off
@ -390,24 +392,26 @@ void loadT55xxConfig(void) {
* @param period_1
* @param command (in binary char array)
*/
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint16_t period_1, uint8_t *symbol_extra, uint16_t *period_extra, uint8_t *command, bool verbose, uint32_t samples, bool ledcontrol) {
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint16_t period_1, uint8_t *symbol_extra, uint16_t *period_extra, uint8_t *command, bool verbose, bool keep_field_on, uint32_t samples, bool ledcontrol) {
if (!prev_keep){
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
}
// use lf config settings
sample_config *sc = getSamplingConfig();
LFSetupFPGAForADC(sc->divisor, true);
// this causes the field to turn on for uncontrolled amount of time, so we'll turn it off
// Make sure the tag is reset
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
if (!prev_keep){
// Make sure the tag is reset
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
}
// start timer
StartTicks();
WaitMS(100);
// clear read buffer
BigBuf_Clear_keep_EM();
@ -494,8 +498,10 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint
DoAcquisition_config(verbose, samples, ledcontrol);
// Turn off antenna
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
if (!keep_field_on) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
}
prev_keep = keep_field_on;
// tell client we are done
reply_ng(CMD_LF_MOD_THEN_ACQ_RAW_ADC, PM3_SUCCESS, NULL, 0);
}

View file

@ -15,7 +15,7 @@
#include "pm3_cmd.h" // struct
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint16_t period_1, uint8_t *symbol_extra, uint16_t *period_extra, uint8_t *command, bool verbose, uint32_t samples, bool ledcontrol);
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint16_t period_1, uint8_t *symbol_extra, uint16_t *period_extra, uint8_t *command, bool verbose, bool keep_field_on, uint32_t samples, bool ledcontrol);
void ReadTItag(bool ledcontrol);
void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc, bool ledcontrol);

View file

@ -231,6 +231,7 @@ int CmdLFCommandRead(const char *Cmd) {
arg_u64_0("z", "zero", "<us>", "ZERO time period"),
arg_u64_0("s", "samples", "<dec>", "number of samples to collect"),
arg_lit0("v", "verbose", "verbose output"),
arg_lit0("k", "keep", "keep signal field ON after receive"),
arg_lit0("@", NULL, "continuous mode"),
arg_param_end
};
@ -249,7 +250,8 @@ int CmdLFCommandRead(const char *Cmd) {
uint16_t period_0 = arg_get_u32_def(ctx, 5, 0);
uint32_t samples = arg_get_u32_def(ctx, 6, 0);
bool verbose = arg_get_lit(ctx, 7);
bool cm = arg_get_lit(ctx, 8);
bool keep_field_on = arg_get_lit(ctx, 8);
bool cm = arg_get_lit(ctx, 9);
CLIParserFree(ctx);
if (g_session.pm3_present == false)
@ -262,7 +264,8 @@ int CmdLFCommandRead(const char *Cmd) {
uint16_t period_1;
uint8_t symbol_extra[LF_CMDREAD_MAX_EXTRA_SYMBOLS];
uint16_t period_extra[LF_CMDREAD_MAX_EXTRA_SYMBOLS];
uint32_t samples : 31;
uint32_t samples : 30;
bool keep_field_on : 1;
bool verbose : 1;
uint8_t data[PM3_CMD_DATA_SIZE - PAYLOAD_HEADER_SIZE];
} PACKED payload;
@ -270,6 +273,7 @@ int CmdLFCommandRead(const char *Cmd) {
payload.period_1 = period_1;
payload.period_0 = period_0;
payload.samples = samples;
payload.keep_field_on = keep_field_on;
payload.verbose = verbose;
memcpy(payload.data, cmd, cmd_len);