From 7bd008dde3d1b54d43c106d7ea85b4ef2f138aa6 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 29 Aug 2020 11:31:03 +0200 Subject: [PATCH] analyze freq, calculates wavelengths. --- client/src/cmdanalyse.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/client/src/cmdanalyse.c b/client/src/cmdanalyse.c index c4fe2d795..b701dbd3b 100644 --- a/client/src/cmdanalyse.c +++ b/client/src/cmdanalyse.c @@ -12,7 +12,7 @@ #include // size_t #include #include // tolower -#include // printf +//#include // printf #include "commonutil.h" // reflect... #include "comms.h" // clearCommandBuffer #include "cmdparser.h" // command_t @@ -914,16 +914,33 @@ static int CmdAnalyseDemodBuffer(const char *Cmd) { if (c == '0') DemodBuffer[i] = 0; - printf("%c", c); + PrintAndLogEx(NORMAL, "%c" NOLF, c); } - printf("\n"); + PrintAndLogEx(NORMAL, ""); DemodBufferLen = len; free(data); return PM3_SUCCESS; } +static int CmdAnalyseFreq(const char *Cmd) { + +// char cmdp = tolower(param_getchar(Cmd, 0)); +// if (strlen(Cmd) == 0 || cmdp == 'h') return usage_analyse_freq(); + + const double c = 299792458; + double len_125 = c / 125000; + double len_134 = c / 134000; + double len_1356 = c / 13560000; + + PrintAndLogEx(INFO, "Wavelengths"); + PrintAndLogEx(INFO, " 125 kHz has %f meters", len_125); + PrintAndLogEx(INFO, " 134 kHz has %f meters", len_134); + PrintAndLogEx(INFO, " 13.56 mHz has %f meters", len_1356); + return PM3_SUCCESS; +} + static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"lcr", CmdAnalyseLCR, AlwaysAvailable, "Generate final byte for XOR LRC"}, @@ -934,7 +951,8 @@ static command_t CommandTable[] = { {"lfsr", CmdAnalyseLfsr, AlwaysAvailable, "LFSR tests"}, {"a", CmdAnalyseA, AlwaysAvailable, "num bits test"}, {"nuid", CmdAnalyseNuid, AlwaysAvailable, "create NUID from 7byte UID"}, - {"demodbuff", CmdAnalyseDemodBuffer, AlwaysAvailable, "Load binary string to demodbuffer"}, + {"demodbuff", CmdAnalyseDemodBuffer, AlwaysAvailable, "Load binary string to demodbuffer"}, + {"freq", CmdAnalyseFreq, AlwaysAvailable, "Calc wave lengths"}, {NULL, NULL, NULL, NULL} };