X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/0fb65a262bcc005402f3c18aa460dc61129323d0..fbf77474f53809f57e8d32a8e6e210bf921c424b:/client/cmdlfindala.c

diff --git a/client/cmdlfindala.c b/client/cmdlfindala.c
index 1a1d2a06..02c906d0 100644
--- a/client/cmdlfindala.c
+++ b/client/cmdlfindala.c
@@ -5,12 +5,14 @@
 // the license.
 //-----------------------------------------------------------------------------
 // Low frequency Indala commands
+// PSK1, rf/32, 64 or 224 bits (known)
 //-----------------------------------------------------------------------------
 
+#include "cmdlfindala.h"
+
 #include <stdio.h>
 #include <string.h>
-#include "cmdlfindala.h"
-#include "proxmark3.h"
+#include "comms.h"
 #include "ui.h"
 #include "graph.h"
 #include "cmdparser.h"
@@ -34,19 +36,24 @@ int CmdIndalaDecode(const char *Cmd) {
 	}
 
 	if (!ans) {
-	if (g_debugMode) 
-		PrintAndLog("Error1: %i",ans);
+		if (g_debugMode) PrintAndLog("Error1: %i",ans);
 		return 0;
 	}
 	uint8_t invert=0;
 	size_t size = DemodBufferLen;
-	int startIdx = indala26decode(DemodBuffer, &size, &invert);
-	if (startIdx < 0 || size > 224) {
-		if (g_debugMode)
-		PrintAndLog("Error2: %i",startIdx);
-		return -1;
+	int startIdx = indala64decode(DemodBuffer, &size, &invert);
+	if (startIdx < 0 || size != 64) {
+		// try 224 indala
+		invert = 0;
+		size = DemodBufferLen;
+		startIdx = indala224decode(DemodBuffer, &size, &invert);
+		if (startIdx < 0 || size != 224) {
+			if (g_debugMode) PrintAndLog("Error2: %i",startIdx);
+			return -1;
+		}
 	}
 	setDemodBuf(DemodBuffer, size, (size_t)startIdx);
+	setClockGrid(g_DemodClock, g_DemodStartIdx + (startIdx*g_DemodClock));
 	if (invert)
 		if (g_debugMode)
 			PrintAndLog("Had to invert bits");
@@ -75,8 +82,7 @@ int CmdIndalaDecode(const char *Cmd) {
 }
 
 int CmdIndalaRead(const char *Cmd) {
-	CmdLFRead("s");
-	getSamples("30000",false);
+	lf_read(true, 30000);
 	return CmdIndalaDecode("");
 }
 
@@ -97,8 +103,12 @@ int CmdIndalaDemod(const char *Cmd) {
 	uint8_t rawbits[4096];
 	int rawbit = 0;
 	int worst = 0, worstPos = 0;
-	// PrintAndLog("Expecting a bit less than %d raw bits", GraphTraceLen / 32);
+
+	//clear clock grid and demod plot
+	setClockGrid(0, 0);
+	DemodBufferLen = 0;
 	
+	// PrintAndLog("Expecting a bit less than %d raw bits", GraphTraceLen / 32);
 	// loop through raw signal - since we know it is psk1 rf/32 fc/2 skip every other value (+=2)
 	for (i = 0; i < GraphTraceLen-1; i += 2) {
 		count += 1;
@@ -277,7 +287,7 @@ int CmdIndalaDemod(const char *Cmd) {
 }
 
 int CmdIndalaClone(const char *Cmd) {
-	UsbCommand c;
+	UsbCommand c = {0};
 	unsigned int uid1, uid2, uid3, uid4, uid5, uid6, uid7;
 
 	uid1 =  uid2 = uid3 = uid4 = uid5 = uid6 = uid7 = 0;