]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmddata.c
FIX: added a break if the device starts acting strange when aquirering data from...
[proxmark3-svn] / client / cmddata.c
index 3d56a971b182ea8476d2b12566176fe0e84390d8..aeabd985612af6c7f2a1a02be2f223b07fa0ae58 100644 (file)
@@ -635,6 +635,32 @@ int CmdG_Prox_II_Demod(const char *Cmd)
        return 1;
 }
 
+//by marshmellow
+//see ASKDemod for what args are accepted
+int CmdVikingDemod(const char *Cmd)
+{
+       if (!ASKDemod(Cmd, false, false, 1)) {
+               if (g_debugMode) PrintAndLog("ASKDemod failed");
+               return 0;
+       }
+       size_t size = DemodBufferLen;
+       //call lfdemod.c demod for Viking
+       int ans = VikingDemod_AM(DemodBuffer, &size);
+       if (ans < 0) {
+               if (g_debugMode) PrintAndLog("Error Viking_Demod %d", ans);
+               return 0;
+       }
+       //got a good demod
+       uint32_t raw1 = bytebits_to_byte(DemodBuffer+ans, 32);
+       uint32_t raw2 = bytebits_to_byte(DemodBuffer+ans+32, 32);
+       uint32_t cardid = bytebits_to_byte(DemodBuffer+ans+24, 32);
+       uint8_t  checksum = bytebits_to_byte(DemodBuffer+ans+32+24, 8);
+       PrintAndLog("Viking Tag Found: Card ID %08X, Checksum: %02X", cardid, checksum);
+       PrintAndLog("Raw: %08X%08X", raw1,raw2);
+       setDemodBuf(DemodBuffer+ans, 64, 0);
+       return 1;
+}
+
 //by marshmellow - see ASKDemod
 int Cmdaskrawdemod(const char *Cmd)
 {
@@ -1128,8 +1154,6 @@ int CmdFSKdemodParadox(const char *Cmd)
 //print ioprox ID and some format details
 int CmdFSKdemodIO(const char *Cmd)
 {
-       //raw fsk demod no manchester decoding no start bit finding just get binary from wave
-       //set defaults
        int idx=0;
        //something in graphbuffer?
        if (GraphTraceLen < 65) {
@@ -1218,7 +1242,6 @@ int CmdFSKdemodIO(const char *Cmd)
 //print full AWID Prox ID and some bit format details if found
 int CmdFSKdemodAWID(const char *Cmd)
 {
-       //raw fsk demod no manchester decoding no start bit finding just get binary from wave
        uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
        size_t size = getFromGraphBuf(BitStream);
        if (size==0) return 0;
@@ -1964,7 +1987,11 @@ int getSamples(const char *Cmd, bool silent)
        GetFromBigBuf(got,n,0);
        PrintAndLog("Data fetched");
        UsbCommand response;
-       WaitForResponse(CMD_ACK, &response);
+       if ( !WaitForResponseTimeout(CMD_ACK, &response, 10000) ) {
+        PrintAndLog("timeout while waiting for reply.");
+               return 1;
+    }
+       
        uint8_t bits_per_sample = 8;
 
        //Old devices without this feature would send 0 at arg[0]
@@ -2007,9 +2034,9 @@ int CmdTuneSamples(const char *Cmd)
        int timeout = 0;
        printf("\nMeasuring antenna characteristics, please wait...");
 
-       UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING};
+       UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING, {0,0,0}};
+       clearCommandBuffer();
        SendCommand(&c);
-
        UsbCommand resp;
        while(!WaitForResponseTimeout(CMD_MEASURED_ANTENNA_TUNING,&resp,1000)) {
                timeout++;
@@ -2057,7 +2084,6 @@ int CmdTuneSamples(const char *Cmd)
                ShowGraphWindow();
                RepaintGraphWindow();
        }
-
        return 0;
 }
 
@@ -2073,7 +2099,7 @@ int CmdLoad(const char *Cmd)
        
        FILE *f = fopen(filename, "r");
        if (!f) {
-                PrintAndLog("couldn't open '%s'", filename);
+               PrintAndLog("couldn't open '%s'", filename);
                return 0;
        }
 
@@ -2092,11 +2118,13 @@ int CmdLoad(const char *Cmd)
 int CmdLtrim(const char *Cmd)
 {
        int ds = atoi(Cmd);
-       if (GraphTraceLen<=0) return 0;
+
+       if (GraphTraceLen <= 0) return 0;
+
        for (int i = ds; i < GraphTraceLen; ++i)
                GraphBuffer[i-ds] = GraphBuffer[i];
-       GraphTraceLen -= ds;
 
+       GraphTraceLen -= ds;
        RepaintGraphWindow();
        return 0;
 }
@@ -2105,9 +2133,7 @@ int CmdLtrim(const char *Cmd)
 int CmdRtrim(const char *Cmd)
 {
        int ds = atoi(Cmd);
-
        GraphTraceLen = ds;
-
        RepaintGraphWindow();
        return 0;
 }
@@ -2373,7 +2399,7 @@ static command_t CommandTable[] =
        {"samples",         CmdSamples,         0, "[512 - 40000] -- Get raw samples for graph window (GraphBuffer)"},
        {"save",            CmdSave,            1, "<filename> -- Save trace (from graph window)"},
        {"scale",           CmdScale,           1, "<int> -- Set cursor display scale"},
-       {"setdebugmode",    CmdSetDebugMode,    1, "<0|1> -- Turn on or off Debugging Mode for demods"},
+       {"setdebugmode",    CmdSetDebugMode,    1, "<0|1|2> -- Turn on or off Debugging Level for lf demods"},
        {"shiftgraphzero",  CmdGraphShiftZero,  1, "<shift> -- Shift 0 for Graphed wave + or - shift value"},
        {"dirthreshold",    CmdDirectionalThreshold,   1, "<thres up> <thres down> -- Max rising higher up-thres/ Min falling lower down-thres, keep rest as prev."},
        {"tune",            CmdTuneSamples,     0, "Get hw tune samples for graph window"},
Impressum, Datenschutz