From 1208eb9e100c5154d5a8f804a4446ced2cb4b37d Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Wed, 16 Sep 2020 02:38:28 +0200 Subject: [PATCH] Add option for continuous mode to `lf read`, try e.g. `data plot` then `lf read d 3000 s c` --- CHANGELOG.md | 1 + client/src/cmdlf.c | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55d26c791..786d2c0e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] + - Add option for continuous mode to `lf read`, try e.g. `data plot` then `lf read d 3000 s c` (@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) - Mikron JSC Russia Ultralight EV1 41 pages tag type support (@McEloff) diff --git a/client/src/cmdlf.c b/client/src/cmdlf.c index 165108fb8..eb79ca193 100644 --- a/client/src/cmdlf.c +++ b/client/src/cmdlf.c @@ -77,14 +77,16 @@ static int usage_lf_cmdread(void) { return PM3_SUCCESS; } static int usage_lf_read(void) { - PrintAndLogEx(NORMAL, "Usage: lf read [h] [s] [d numofsamples]"); + PrintAndLogEx(NORMAL, "Usage: lf read [h] [s] [d numofsamples] [c]"); PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, " h This help"); PrintAndLogEx(NORMAL, " d #samples # samples to collect (optional)"); PrintAndLogEx(NORMAL, " s silent"); + PrintAndLogEx(NORMAL, " c run continuously until a key is pressed"); PrintAndLogEx(NORMAL, ""); 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, "Extras:"); PrintAndLogEx(NORMAL, " use " _YELLOW_("'lf config'")" to set parameters."); @@ -627,6 +629,7 @@ int CmdLFRead(const char *Cmd) { bool errors = false; bool verbose = true; + bool continuous = false; uint32_t samples = 0; uint8_t cmdp = 0; while (param_getchar(Cmd, cmdp) != 0x00 && !errors) { @@ -641,6 +644,10 @@ int CmdLFRead(const char *Cmd) { verbose = false; cmdp++; break; + case 'c': + continuous = true; + cmdp++; + break; default: PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp)); errors = true; @@ -650,8 +657,17 @@ int CmdLFRead(const char *Cmd) { //Validations if (errors) return usage_lf_read(); - - return lf_read(verbose, samples); + if (continuous) { + PrintAndLogEx(INFO, "Press " _GREEN_("Enter") " to exit"); + } + int ret = PM3_SUCCESS; + do { + ret = lf_read(verbose, samples); + if (kbd_enter_pressed()) { + break; + } + } while (continuous); + return ret; } int CmdLFSniff(const char *Cmd) {