X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/c15d2bdc9b25da89931c767902639fa7e8c9b764..a501c82b196b614295a6e3bf7481da84affb0d8e:/client/cmddata.c diff --git a/client/cmddata.c b/client/cmddata.c index 1df3486d..a1a0d484 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -461,7 +461,7 @@ int CmdSamples(const char *Cmd) int n = strtol(Cmd, NULL, 0); if (n == 0) - n = 512; + n = 16000; if (n > sizeof(got)) n = sizeof(got); @@ -475,14 +475,40 @@ 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) { - FILE *f = fopen(Cmd, "r"); - if (!f) { - PrintAndLog("couldn't open '%s'", Cmd); - return 0; - } + char filename[FILE_PATH_SIZE] = {0x00}; + int len = 0; + + len = strlen(Cmd); + if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE; + memcpy(filename, Cmd, len); + + FILE *f = fopen(filename, "r"); + if (!f) { + PrintAndLog("couldn't open '%s'", filename); + return 0; + } GraphTraceLen = 0; char line[80]; @@ -780,9 +806,17 @@ int CmdPlot(const char *Cmd) int CmdSave(const char *Cmd) { - FILE *f = fopen(Cmd, "w"); + char filename[FILE_PATH_SIZE] = {0x00}; + int len = 0; + + len = strlen(Cmd); + if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE; + memcpy(filename, Cmd, len); + + + FILE *f = fopen(filename, "w"); if(!f) { - PrintAndLog("couldn't open '%s'", Cmd); + PrintAndLog("couldn't open '%s'", filename); return 0; } int i; @@ -894,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"}, @@ -909,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} };