From d6d20c543547d12eff81c5c3de254cf4b8650868 Mon Sep 17 00:00:00 2001 From: marshmellow42 Date: Wed, 7 Jan 2015 19:06:29 -0500 Subject: [PATCH] cmddata.c changes by others - reapply i overwrote some changes in cmdsamples. i fixed that i also removed some comments in graph.c --- client/cmddata.c | 58 +++++++++++------------------------------------- client/graph.c | 36 ++---------------------------- 2 files changed, 15 insertions(+), 79 deletions(-) diff --git a/client/cmddata.c b/client/cmddata.c index 657a118b..53a3ce5f 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -932,35 +932,6 @@ int CmdIndalaDecode(const char *Cmd) return 1; } -/* -//by marshmellow (attempt to get rid of high immediately after a low) -void pskCleanWave2(uint8_t *bitStream, int bitLen) -{ - int i; - int low=128; - int gap = 4; - // int loopMax = 2048; - int newLow=0; - - for (i=0; i sizeof(got)) n = sizeof(got); + int n = strtol(Cmd, NULL, 0); + if (n == 0) + n = 20000; + + if (n > sizeof(got)) + n = sizeof(got); - PrintAndLog("Reading %d samples\n", n); + PrintAndLog("Reading %d samples from device memory\n", n); GetFromBigBuf(got,n,0); WaitForResponse(CMD_ACK,NULL); for (int j = 0; j < n; j++) { - GraphBuffer[cnt++] = ((int)got[j]) - 128; + GraphBuffer[j] = ((int)got[j]) - 128; } - - PrintAndLog("Done!\n"); GraphTraceLen = n; RepaintGraphWindow(); return 0; @@ -1558,8 +1526,8 @@ static command_t CommandTable[] = {"help", CmdHelp, 1, "This help"}, {"amp", CmdAmp, 1, "Amplify peaks"}, {"askdemod", Cmdaskdemod, 1, "<0 or 1> -- Attempt to demodulate simple ASK tags"}, - {"askmandemod", Cmdaskmandemod, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate ASK/Manchester tags and output binary (args optional[clock will try Auto-detect])"}, - {"askrawdemod", Cmdaskrawdemod, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate ASK tags and output binary (args optional[clock will try Auto-detect])"}, + {"askmandemod", Cmdaskmandemod, 1, "[clock] [invert<0|1>] -- Attempt to demodulate ASK/Manchester tags and output binary (args optional[clock will try Auto-detect])"}, + {"askrawdemod", Cmdaskrawdemod, 1, "[clock] [invert<0|1>] -- Attempt to demodulate ASK tags and output binary (args optional[clock will try Auto-detect])"}, {"autocorr", CmdAutoCorr, 1, " -- Autocorrelation over window"}, {"biphaserawdecode",CmdBiphaseDecodeRaw,1,"[offset] Biphase decode binary stream already in graph buffer (offset = bit to start decode from)"}, {"bitsamples", CmdBitsamples, 0, "Get raw samples as bitstring"}, @@ -1570,7 +1538,7 @@ static command_t CommandTable[] = {"fskdemod", CmdFSKdemod, 1, "Demodulate graph window as a HID FSK"}, {"fskhiddemod", CmdFSKdemodHID, 1, "Demodulate graph window as a HID FSK using raw"}, {"fskiodemod", CmdFSKdemodIO, 1, "Demodulate graph window as an IO Prox FSK using raw"}, - {"fskrawdemod", CmdFSKrawdemod, 1, "[clock rate] [invert] [rchigh] [rclow] Demodulate graph window from FSK to binary (clock = 50)(invert = 1 or 0)(rchigh = 10)(rclow=8)"}, + {"fskrawdemod", CmdFSKrawdemod, 1, "[clock rate] [invert] [rchigh] [rclow] Demodulate graph window from FSK to binary (clock = 50)(invert = 1|0)(rchigh = 10)(rclow=8)"}, {"grid", CmdGrid, 1, " -- overlay grid on graph window, use zero value to turn off either"}, {"hexsamples", CmdHexsamples, 0, " [] -- Dump big buffer as hex bytes"}, {"hide", CmdHide, 1, "Hide graph window"}, @@ -1585,8 +1553,8 @@ static command_t CommandTable[] = {"plot", CmdPlot, 1, "Show graph window (hit 'h' in window for keystroke help)"}, {"pskclean", CmdPskClean, 1, "Attempt to clean psk wave"}, {"pskdetectclock",CmdDetectNRZpskClockRate, 1, "Detect ASK, PSK, or NRZ clock rate"}, - {"pskindalademod",CmdIndalaDecode, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate psk indala tags and output ID binary & hex (args optional[clock will try Auto-detect])"}, - {"psknrzrawdemod",CmdpskNRZrawDemod, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate psk or nrz tags and output binary (args optional[clock will try Auto-detect])"}, + {"pskindalademod",CmdIndalaDecode, 1, "[clock] [invert<0|1>] -- Attempt to demodulate psk indala tags and output ID binary & hex (args optional[clock will try Auto-detect])"}, + {"psknrzrawdemod",CmdpskNRZrawDemod, 1, "[clock] [invert<0|1>] -- Attempt to demodulate psk or nrz tags and output binary (args optional[clock will try Auto-detect])"}, {"samples", CmdSamples, 0, "[512 - 40000] -- Get raw samples for graph window"}, {"save", CmdSave, 1, " -- Save trace (from graph window)"}, {"scale", CmdScale, 1, " -- Set cursor display scale"}, diff --git a/client/graph.c b/client/graph.c index f41568e4..e03d1a51 100644 --- a/client/graph.c +++ b/client/graph.c @@ -166,7 +166,6 @@ size_t getFromGraphBuf(uint8_t *buff) int GetClock(const char *str, int peak, int verbose) { int clock; -// int clock2; sscanf(str, "%i", &clock); if (!strcmp(str, "")) clock = 0; @@ -177,46 +176,18 @@ int GetClock(const char *str, int peak, int verbose) uint8_t grph[MAX_GRAPH_TRACE_LEN]={0}; size_t size = getFromGraphBuf(grph); clock = DetectASKClock(grph,size,0); - //clock2 = DetectClock2(peak); /* Only print this message if we're not looping something */ if (!verbose){ PrintAndLog("Auto-detected clock rate: %d", clock); - //PrintAndLog("clock2: %d",clock2); } } return clock; } -int GetNRZpskClock(const char *str, int peak, int verbose) -{ - // return GetClock(str,peak,verbose); - int clock; - // int clock2; - sscanf(str, "%i", &clock); - if (!strcmp(str, "")) - clock = 0; - /* Auto-detect clock */ - if (!clock) - { - uint8_t grph[MAX_GRAPH_TRACE_LEN]={0}; - size_t size = getFromGraphBuf(grph); - clock = DetectpskNRZClock(grph,size,0); - //clock2 = DetectClock2(peak); - /* Only print this message if we're not looping something */ - if (!verbose){ - PrintAndLog("Auto-detected clock rate: %d", clock); - //PrintAndLog("clock2: %d",clock2); - } - } - return clock; -} -// Get or auto-detect clock rate -/* int GetNRZpskClock(const char *str, int peak, int verbose) { int clock; -// int clock2; sscanf(str, "%i", &clock); if (!strcmp(str, "")) clock = 0; @@ -225,15 +196,12 @@ int GetNRZpskClock(const char *str, int peak, int verbose) if (!clock) { uint8_t grph[MAX_GRAPH_TRACE_LEN]={0}; - int size = getFromGraphBuf(grph); - clock = DetectASKClock(grph,size,0); - //clock2 = DetectClock2(peak); + size_t size = getFromGraphBuf(grph); + clock = DetectpskNRZClock(grph,size,0); // Only print this message if we're not looping something if (!verbose){ PrintAndLog("Auto-detected clock rate: %d", clock); - //PrintAndLog("clock2: %d",clock2); } } return clock; } -*/ -- 2.39.2