From: marshmellow42 Date: Tue, 28 Feb 2017 22:28:51 +0000 (-0500) Subject: fix stt mark location bug X-Git-Tag: v3.0.0~62^2~1 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/f75b313b002369372bc97066a90a1593ebc2e25c?ds=sidebyside;hp=--cc fix stt mark location bug add `data mtrim` to do a middle trim of the graph. --- f75b313b002369372bc97066a90a1593ebc2e25c diff --git a/client/cmddata.c b/client/cmddata.c index 75ead7a6..2a83a4d4 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -348,7 +348,7 @@ int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType, clk = (clk == 0) ? foundclk : clk; CursorCPos = ststart; CursorDPos = stend; - if (verbose || g_debugMode) PrintAndLog("\nFound Sequence Terminator - Second one is shown by orange and blue graph markers"); + if (verbose || g_debugMode) PrintAndLog("\nFound Sequence Terminator - First one is shown by orange and blue graph markers"); } int errCnt = askdemod(BitStream, &BitLen, &clk, &invert, maxErr, askamp, askType); if (errCnt<0 || BitLen<16){ //if fatal error (or -1) @@ -2169,6 +2169,22 @@ int CmdRtrim(const char *Cmd) return 0; } +// trim graph (middle) piece +int CmdMtrim(const char *Cmd) { + int start = 0, stop = 0; + sscanf(Cmd, "%i %i", &start, &stop); + + if (start > GraphTraceLen || stop > GraphTraceLen || start > stop) return 0; + start++; //leave start position sample + + GraphTraceLen -= stop - start; + for (int i = 0; i < GraphTraceLen; i++) { + GraphBuffer[start+i] = GraphBuffer[stop+i]; + } + return 0; +} + + int CmdNorm(const char *Cmd) { int i; @@ -2419,6 +2435,7 @@ static command_t CommandTable[] = {"load", CmdLoad, 1, " -- Load trace (to graph window"}, {"ltrim", CmdLtrim, 1, " -- Trim samples from left of trace"}, {"rtrim", CmdRtrim, 1, " -- Trim samples from right of trace"}, + {"mtrim", CmdMtrim, 1, " -- Trim out samples from the specified start to the specified stop"}, {"manrawdecode", Cmdmandecoderaw, 1, "[invert] [maxErr] -- Manchester decode binary stream in DemodBuffer"}, {"norm", CmdNorm, 1, "Normalize max/min to +/-128"}, {"plot", CmdPlot, 1, "Show graph window (hit 'h' in window for keystroke help)"}, diff --git a/common/lfdemod.c b/common/lfdemod.c index b067098d..3f597a1f 100644 --- a/common/lfdemod.c +++ b/common/lfdemod.c @@ -1770,8 +1770,8 @@ bool DetectST_ext(uint8_t buffer[], size_t *size, int *foundclock, size_t *ststa buffer[dataloc+1] = buffer[dataloc+2]; } if (firstrun) { - *ststart = dataloc; - *stend = dataloc+(clk*4); + *stend = dataloc; + *ststart = dataloc-(clk*4); firstrun=false; } for (i=0; i