From cad1d500ca928f34c607a05d6eff955eaeb71a0b Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 15 Jul 2019 00:31:38 +0200 Subject: [PATCH] add msleep command --- client/cmdmain.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/client/cmdmain.c b/client/cmdmain.c index 311e2d6de..6748f81f0 100644 --- a/client/cmdmain.c +++ b/client/cmdmain.c @@ -31,6 +31,32 @@ static int CmdRem(const char *Cmd) { return PM3_SUCCESS; } +static int usage_msleep(void) { + PrintAndLogEx(NORMAL, "Sleep for given amount of milliseconds"); + PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(NORMAL, "Usage: msleep "); + PrintAndLogEx(NORMAL, "Options:"); + PrintAndLogEx(NORMAL, " h This help"); + PrintAndLogEx(NORMAL, " time in milliseconds"); + PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(NORMAL, "Examples:"); + PrintAndLogEx(NORMAL, " msleep 100"); + return PM3_SUCCESS; +} + +static int CmdMsleep(const char *Cmd) { + uint32_t ms = 0; + char ctmp = tolower(param_getchar(Cmd, 0)); + if (strlen(Cmd) < 1 || ctmp == 'h') return usage_msleep(); + if (param_getchar(Cmd, 0) != 0x00) { + ms = param_get32ex(Cmd, 0, 0, 10); + if (ms == 0) + return usage_msleep(); + } + msleep(ms); + return PM3_SUCCESS; +} + static int CmdQuit(const char *Cmd) { (void)Cmd; // Cmd is not used so far return PM3_EFATAL; @@ -50,8 +76,9 @@ static command_t CommandTable[] = { {"hw", CmdHW, AlwaysAvailable, "{ Hardware commands... }"}, {"lf", CmdLF, AlwaysAvailable, "{ Low Frequency commands... }"}, {"mem", CmdFlashMem, IfPm3Flash, "{ Flash Memory manipulation... }"}, - {"rem", CmdRem, AlwaysAvailable, "{ Add text to row in log file }"}, - {"reveng", CmdRev, AlwaysAvailable, "{ Crc calculations from the RevEng software... }"}, + {"msleep", CmdMsleep, AlwaysAvailable, "Add a pause in milliseconds"}, + {"rem", CmdRem, AlwaysAvailable, "Add text to row in log file"}, + {"reveng", CmdRev, AlwaysAvailable, "{ Crc calculations from the RevEng software }"}, {"sc", CmdSmartcard, IfPm3Smartcard, "{ Smart card ISO7816 commands... }"}, {"script", CmdScript, AlwaysAvailable, "{ Scripting commands }"}, {"trace", CmdTrace, AlwaysAvailable, "{ Trace manipulation... }"},