]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
fix stt mark location bug
authormarshmellow42 <marshmellowrf@gmail.com>
Tue, 28 Feb 2017 22:28:51 +0000 (17:28 -0500)
committermarshmellow42 <marshmellowrf@gmail.com>
Tue, 28 Feb 2017 22:28:51 +0000 (17:28 -0500)
add `data mtrim` to do a middle trim of the graph.

client/cmddata.c
common/lfdemod.c

index 75ead7a60b9a76a565956175482e9b7c7878791c..2a83a4d49c376ec9f010e2d5d358971947c453ee 100644 (file)
@@ -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, "<filename> -- Load trace (to graph window"},
        {"ltrim",           CmdLtrim,           1, "<samples> -- Trim samples from left of trace"},
        {"rtrim",           CmdRtrim,           1, "<location to end trace> -- Trim samples from right of trace"},
+       {"mtrim",           CmdMtrim,           1, "<start> <stop> -- 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)"},
index b067098d9044555fd511692cb1a44e37fd84ea6f..3f597a1ff053cd69fdb1669f39a8966dda2ab0cb 100644 (file)
@@ -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<datalen; ++i) {
Impressum, Datenschutz