]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmddata.c
Merge branch 'master' of https://github.com/iceman1001/proxmark3
[proxmark3-svn] / client / cmddata.c
index 14140e638b0aa2ca451caa7555de050a648891c8..acb1359e8c13d93c7e29f89176542c18418c66fa 100644 (file)
@@ -258,8 +258,7 @@ void setDemodBuf(uint8_t *buff, size_t size, size_t startIdx)
        for (; i < size; i++){
                DemodBuffer[i]=buff[startIdx++];
        }
-       DemodBufferLen=size;
-       return;
+       DemodBufferLen = size;
 }
 
 int CmdSetDebugMode(const char *Cmd)
@@ -970,17 +969,17 @@ int CmdUndec(const char *Cmd)
 //shift graph zero up or down based on input + or -
 int CmdGraphShiftZero(const char *Cmd)
 {
-       int shift=0;
+       int shift = 0, shiftedVal = 0;
        //set options from parameters entered with the command
        sscanf(Cmd, "%i", &shift);
-       int shiftedVal=0;
+
        for(int i = 0; i<GraphTraceLen; i++){
                shiftedVal=GraphBuffer[i]+shift;
-               if (shiftedVal>127) 
-                       shiftedVal=127;
-               else if (shiftedVal<-127) 
-                       shiftedVal=-127;
-               GraphBuffer[i]= shiftedVal;
+               if (shiftedVal > 127) 
+                       shiftedVal = 127;
+               else if (shiftedVal < -127) 
+                       shiftedVal = -127;
+               GraphBuffer[i] = shiftedVal;
        }
        CmdNorm("");
        return 0;
@@ -1761,7 +1760,8 @@ int CmdIndalaDecode(const char *Cmd)
                        PrintAndLog("Error1: %d",ans);
                return 0;
        }
-       uint8_t invert=0;
+
+       uint8_t invert = 0;
        size_t size = DemodBufferLen;
        int startIdx = indala26decode(DemodBuffer, &size, &invert);
        if (startIdx < 0 || size > 224) {
@@ -1800,12 +1800,18 @@ int CmdIndalaDecode(const char *Cmd)
 int CmdPSKNexWatch(const char *Cmd)
 {
        if (!PSKDemod("", false)) return 0;
+
        uint8_t preamble[28] = {0,0,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
        size_t startIdx = 0, size = DemodBufferLen; 
+       
+       // sanity check. 
+       if ( size < sizeof(preamble) + 100) return 0;
+       
        bool invert = false;
        if (!preambleSearch(DemodBuffer, preamble, sizeof(preamble), &size, &startIdx)){
                // if didn't find preamble try again inverting
                if (!PSKDemod("1", false)) return 0; 
+
                size = DemodBufferLen;
                if (!preambleSearch(DemodBuffer, preamble, sizeof(preamble), &size, &startIdx)) return 0;
                invert = true;
@@ -1906,7 +1912,6 @@ int CmdPSK1rawDemod(const char *Cmd)
                if (g_debugMode) PrintAndLog("Error demoding: %d",ans); 
                return 0;
        }
        PrintAndLog("PSK1 demoded bitstream:");
        // Now output the bitstream to the scrollback by line of 16 bits
        printDemodBuff();
@@ -1917,12 +1922,12 @@ int CmdPSK1rawDemod(const char *Cmd)
 // takes same args as cmdpsk1rawdemod
 int CmdPSK2rawDemod(const char *Cmd)
 {
-       int ans=0;
+       int ans = 0;
        char cmdp = param_getchar(Cmd, 0);
        if (strlen(Cmd) > 10 || cmdp == 'h' || cmdp == 'H')
                return usage_data_rawdemod_p2();
 
-       ans=PSKDemod(Cmd, TRUE);
+       ans = PSKDemod(Cmd, TRUE);
        if (!ans){
                if (g_debugMode) PrintAndLog("Error demoding: %d",ans);  
                return 0;
@@ -2141,10 +2146,14 @@ int CmdTuneSamples(const char *Cmd)
        peakf = resp.arg[2] & 0xffff;
        peakv = resp.arg[2] >> 16;
        PrintAndLog("");
-       PrintAndLog("# LF antenna: %5.2f V @   125.00 kHz", vLf125/1000.0);
-       PrintAndLog("# LF antenna: %5.2f V @   134.00 kHz", vLf134/1000.0);
-       PrintAndLog("# LF optimal: %5.2f V @%9.2f kHz", peakv/1000.0, 12000.0/(peakf+1));
-       PrintAndLog("# HF antenna: %5.2f V @    13.56 MHz", vHf/1000.0);
+       if ( vLf125 > 0 )
+               PrintAndLog("# LF antenna: %5.2f V @   125.00 kHz", vLf125/1000.0);
+       if ( vLf134 > 0 )
+               PrintAndLog("# LF antenna: %5.2f V @   134.00 kHz", vLf134/1000.0);
+       if ( peakv > 0 && peakf > 0 )
+               PrintAndLog("# LF optimal: %5.2f V @%9.2f kHz", peakv/1000.0, 12000.0/(peakf+1));
+       if ( vHf > 0 )
+               PrintAndLog("# HF antenna: %5.2f V @    13.56 MHz", vHf/1000.0);
 
  #define LF_UNUSABLE_V         2948            // was 2000. Changed due to bugfix in voltage measurements. LF results are now 47% higher.
  #define LF_MARGINAL_V         14739           // was 10000. Changed due to bugfix bug in voltage measurements. LF results are now 47% higher.
@@ -2417,7 +2426,10 @@ int Cmdhex2bin(const char *Cmd)
 }
 
 int CmdDataIIR(const char *Cmd){
-       iceIIR_Butterworth(GraphBuffer, GraphTraceLen);
+
+       uint8_t k = param_get8(Cmd,0);
+       //iceIIR_Butterworth(GraphBuffer, GraphTraceLen);
+       iceSimple_Filter(GraphBuffer, GraphTraceLen, k);
        RepaintGraphWindow();
        return 0;
 }
@@ -2425,17 +2437,17 @@ int CmdDataIIR(const char *Cmd){
 static command_t CommandTable[] =
 {
        {"help",            CmdHelp,            1, "This help"},
-       {"askedgedetect",   CmdAskEdgeDetect,   1, "[threshold] Adjust Graph for manual ask demod using the length of sample differences to detect the edge of a wave (use 20-45, def:25)"},
+       {"askedgedetect",   CmdAskEdgeDetect,   1, "[threshold] Adjust Graph for manual ASK demod using the length of sample differences to detect the edge of a wave (use 20-45, def:25)"},
        {"askem410xdemod",  CmdAskEM410xDemod,  1, "[clock] [invert<0|1>] [maxErr] -- Demodulate an EM410x tag from GraphBuffer (args optional)"},
        {"askgproxiidemod", CmdG_Prox_II_Demod, 1, "Demodulate a G Prox II tag from GraphBuffer"},
        {"askvikingdemod",  CmdVikingDemod,     1, "Demodulate a Viking AM tag from GraphBuffer"},
        {"autocorr",        CmdAutoCorr,        1, "[window length] [g] -- Autocorrelation over window - g to save back to GraphBuffer (overwrite)"},
        {"biphaserawdecode",CmdBiphaseDecodeRaw,1, "[offset] [invert<0|1>] [maxErr] -- Biphase decode bin stream in DemodBuffer (offset = 0|1 bits to shift the decode start)"},
-       {"bin2hex",         Cmdbin2hex,         1, "bin2hex <digits>     -- Converts binary to hexadecimal"},
+       {"bin2hex",         Cmdbin2hex,         1, "<digits> -- Converts binary to hexadecimal"},
        {"bitsamples",      CmdBitsamples,      0, "Get raw samples as bitstring"},
        {"buffclear",       CmdBuffClear,       1, "Clear sample buffer and graph window"},
        {"dec",             CmdDec,             1, "Decimate samples"},
-       {"detectclock",     CmdDetectClockRate, 1, "[modulation] Detect clock rate of wave in GraphBuffer (options: 'a','f','n','p' for ask, fsk, nrz, psk respectively)"},
+       {"detectclock",     CmdDetectClockRate, 1, "[<a|f|n|p>] Detect ASK, FSK, NRZ, PSK clock rate of wave in GraphBuffer"},
        {"fdxbdemod",       CmdFDXBdemodBI    , 1, "Demodulate a FDX-B ISO11784/85 Biphase tag from GraphBuffer"},
        {"fskawiddemod",    CmdFSKdemodAWID,    1, "Demodulate an AWID FSK tag from GraphBuffer"},
        //{"fskfcdetect",   CmdFSKfcDetect,     1, "Try to detect the Field Clock of an FSK wave"},
@@ -2446,7 +2458,7 @@ static command_t CommandTable[] =
        {"getbitstream",    CmdGetBitStream,    1, "Convert GraphBuffer's >=1 values to 1 and <1 to 0"},
        {"grid",            CmdGrid,            1, "<x> <y> -- overlay grid on graph window, use zero value to turn off either"},
        {"hexsamples",      CmdHexsamples,      0, "<bytes> [<offset>] -- Dump big buffer as hex bytes"},
-       {"hex2bin",         Cmdhex2bin,         1, "hex2bin <hexadecimal> -- Converts hexadecimal to binary"},
+       {"hex2bin",         Cmdhex2bin,         1, "<hexadecimal> -- Converts hexadecimal to binary"},
        {"hide",            CmdHide,            1, "Hide graph window"},
        {"hpf",             CmdHpf,             1, "Remove DC offset from trace"},
        {"load",            CmdLoad,            1, "<filename> -- Load trace (to graph window"},
Impressum, Datenschutz