From 02306bac2dc44bd1de5422f9db127b231cde304f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 30 Nov 2014 19:16:28 +0100 Subject: [PATCH] ADD: Enio's intuative function for the command: "hw tune", where you plot the tuning-data :) ADD: added optional parameter to "hw tune" to show graf direct. Sample usage: "hw tune p" --- armsrc/appmain.c | 4 ++-- client/cmddata.c | 22 +++++++++++++++++++++- client/cmddata.h | 2 +- client/cmdhw.c | 15 +++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 18c65e80..56467827 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -168,13 +168,13 @@ int AvgAdc(int ch) // was static - merlok void MeasureAntennaTuning(void) { - uint8_t *dest = (uint8_t *)BigBuf+FREE_BUFFER_OFFSET; + uint8_t *dest = (uint8_t *)BigBuf + FREE_BUFFER_OFFSET; int i, adcval = 0, peak = 0, peakv = 0, peakf = 0; //ptr = 0 int vLf125 = 0, vLf134 = 0, vHf = 0; // in mV LED_B_ON(); DbpString("Measuring antenna characteristics, please wait..."); - memset(dest,0,sizeof(FREE_BUFFER_SIZE)); + memset(dest,0,FREE_BUFFER_SIZE); /* * Sweeps the useful LF range of the proxmark from diff --git a/client/cmddata.c b/client/cmddata.c index 9fa26721..b4752b1f 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -475,6 +475,25 @@ int CmdSamples(const char *Cmd) RepaintGraphWindow(); return 0; } +int CmdTuneSamples(const char *Cmd) +{ + int cnt = 0; + int n = 255; + uint8_t got[255] = {0x00}; + + PrintAndLog("Reading %d samples\n", n); + GetFromBigBuf(got,n,7256); // armsrc/apps.h: #define FREE_BUFFER_OFFSET 7256 + WaitForResponse(CMD_ACK,NULL); + for (int j = 0; j < n; j++) { + GraphBuffer[cnt++] = ((int)got[j]) - 128; + } + + PrintAndLog("Done! Divisor 89 is 134khz, 95 is 125khz.\n"); + GraphTraceLen = n; + RepaintGraphWindow(); + return 0; +} + int CmdLoad(const char *Cmd) { @@ -909,6 +928,7 @@ static command_t CommandTable[] = {"buffclear", CmdBuffClear, 1, "Clear sample buffer and graph window"}, {"dec", CmdDec, 1, "Decimate samples"}, {"detectclock", CmdDetectClockRate, 1, "Detect clock rate"}, + {"dirthreshold", CmdDirectionalThreshold, 1, " -- Max rising higher up-thres/ Min falling lower down-thres, keep rest as prev."}, {"fskdemod", CmdFSKdemod, 1, "Demodulate graph window as a HID FSK"}, {"grid", CmdGrid, 1, " -- overlay grid on graph window, use zero value to turn off either"}, {"hexsamples", CmdHexsamples, 0, " [] -- Dump big buffer as hex bytes"}, @@ -924,8 +944,8 @@ static command_t CommandTable[] = {"save", CmdSave, 1, " -- Save trace (from graph window)"}, {"scale", CmdScale, 1, " -- Set cursor display scale"}, {"threshold", CmdThreshold, 1, " -- Maximize/minimize every value in the graph window depending on threshold"}, + {"tune", CmdTuneSamples, 0, "Get hw tune samples for graph window"}, {"zerocrossings", CmdZerocrossings, 1, "Count time between zero-crossings"}, - {"dirthreshold", CmdDirectionalThreshold, 1, " -- Max rising higher up-thres/ Min falling lower down-thres, keep rest as prev."}, {NULL, NULL, 0, NULL} }; diff --git a/client/cmddata.h b/client/cmddata.h index 716c9c39..8073c34c 100644 --- a/client/cmddata.h +++ b/client/cmddata.h @@ -40,5 +40,5 @@ int CmdScale(const char *Cmd); int CmdThreshold(const char *Cmd); int CmdDirectionalThreshold(const char *Cmd); int CmdZerocrossings(const char *Cmd); - +int CmdTuneSamples(const char *Cmd); #endif diff --git a/client/cmdhw.c b/client/cmdhw.c index 68e99276..28cd01ba 100644 --- a/client/cmdhw.c +++ b/client/cmdhw.c @@ -15,6 +15,7 @@ #include "ui.h" #include "proxmark3.h" #include "cmdparser.h" +#include "cmddata.h" #include "cmdhw.h" #include "cmdmain.h" @@ -392,6 +393,20 @@ int CmdTune(const char *Cmd) { UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING}; SendCommand(&c); + + char cmdp = param_getchar(Cmd, 0); + if (cmdp == 'h' || cmdp == 'H') { + PrintAndLog("Usage: hw tune

"); + PrintAndLog(""); + PrintAndLog(" sample: hw tune"); + PrintAndLog(" hw tune p"); + return 0; + } + + if ( cmdp == 'p' || cmdp == 'P'){ + ShowGraphWindow(); + CmdTuneSamples(""); + } return 0; } -- 2.39.5