]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/appmain.c
set svn:ignore
[proxmark3-svn] / armsrc / appmain.c
index 9026f7217792d2709fe8d70c1b0538fa67974769..237159c94b4691eab97bc662af5fb6efdfb5ecad 100644 (file)
 #include "LCD.h"\r
 #endif\r
 \r
+#define va_list __builtin_va_list\r
+#define va_start __builtin_va_start\r
+#define va_arg __builtin_va_arg\r
+#define va_end __builtin_va_end\r
+int kvsprintf(char const *fmt, void *arg, int radix, va_list ap);\r
+       \r
 //=============================================================================\r
 // A buffer where we can queue things up to be sent through the FPGA, for\r
 // any purpose (fake tag, as reader, whatever). We go MSB first, since that\r
@@ -77,6 +83,7 @@ void DbpString(char *str)
        SpinDelay(50);\r
 }\r
 \r
+#if 0\r
 void DbpIntegers(int x1, int x2, int x3)\r
 {\r
        /* this holds up stuff unless we're connected to usb */\r
@@ -93,6 +100,19 @@ void DbpIntegers(int x1, int x2, int x3)
        // XXX\r
        SpinDelay(50);\r
 }\r
+#endif\r
+\r
+void Dbprintf(const char *fmt, ...) {\r
+// should probably limit size here; oh well, let's just use a big buffer\r
+       char output_string[128];\r
+       va_list ap;\r
+\r
+       va_start(ap, fmt);\r
+       kvsprintf(fmt, output_string, 10, ap);\r
+       va_end(ap);\r
\r
+       DbpString(output_string);\r
+}\r
 \r
 //-----------------------------------------------------------------------------\r
 // Read an ADC channel and block till it completes, then return the result\r
@@ -231,12 +251,9 @@ void SimulateTagHfListen(void)
 void ReadMem(int addr)\r
 {\r
        const DWORD *data = ((DWORD *)addr);\r
-       int i;\r
 \r
-       DbpString("Reading memory at address");\r
-       DbpIntegers(0, 0, addr);\r
-       for (i = 0; i < 8; i+= 2)\r
-               DbpIntegers(0, data[i], data[i+1]);\r
+       Dbprintf("%x: %02x %02x %02x %02x %02x %02x %02x %02x",\r
+               addr, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);\r
 }\r
 \r
 /* osimage version information is linked in */\r
@@ -322,8 +339,7 @@ void SamyRun()
                        SpinDelay(500);\r
 \r
                        CmdHIDdemodFSK(1, &high[selected], &low[selected], 0);\r
-                       DbpString("Recorded");\r
-                       DbpIntegers(selected, high[selected], low[selected]);\r
+                       Dbprintf("Recorded %x %x %x", selected, high[selected], low[selected]);\r
 \r
                        LEDsoff();\r
                        LED(selected + 1, 0);\r
@@ -353,7 +369,7 @@ void SamyRun()
                                // wait for button to be released\r
                                while(BUTTON_PRESS())\r
                                        WDT_HIT();\r
-                               DbpIntegers(selected, high[selected], low[selected]);\r
+                               Dbprintf("%x %x %x", selected, high[selected], low[selected]);\r
                                CmdHIDsimTAG(high[selected], low[selected], 0);\r
                                DbpString("Done playing");\r
                                if (BUTTON_HELD(1000) > 0)\r
@@ -431,17 +447,15 @@ void ListenReaderField(int limit)
        lf_av=lf_max=ReadAdc(ADC_CHAN_LF);\r
 \r
        if(limit != HF_ONLY) {\r
-               DbpString("LF 125/134 Baseline:");\r
-               DbpIntegers(lf_av,0,0);\r
-               lf_baseline= lf_av;\r
+               Dbprintf("LF 125/134 Baseline: %d", lf_av);\r
+               lf_baseline = lf_av;\r
        }\r
 \r
        hf_av=hf_max=ReadAdc(ADC_CHAN_HF);\r
 \r
        if (limit != LF_ONLY) {\r
-               DbpString("HF 13.56 Baseline:");\r
-               DbpIntegers(hf_av,0,0);\r
-               hf_baseline= hf_av;\r
+               Dbprintf("HF 13.56 Baseline: %d", hf_av);\r
+               hf_baseline = hf_av;\r
        }\r
 \r
        for(;;) {\r
@@ -472,9 +486,8 @@ void ListenReaderField(int limit)
                        lf_av_new= ReadAdc(ADC_CHAN_LF);\r
                        // see if there's a significant change\r
                        if(abs(lf_av - lf_av_new) > 10) {\r
-                               DbpString("LF 125/134 Field Change:");\r
-                               DbpIntegers(lf_av,lf_av_new,lf_count);\r
-                               lf_av= lf_av_new;\r
+                               Dbprintf("LF 125/134 Field Change: %x %x %x", lf_av, lf_av_new, lf_count);\r
+                               lf_av = lf_av_new;\r
                                if (lf_av > lf_max)\r
                                        lf_max = lf_av;\r
                                lf_count= 0;\r
@@ -491,9 +504,8 @@ void ListenReaderField(int limit)
                        hf_av_new= ReadAdc(ADC_CHAN_HF);\r
                        // see if there's a significant change\r
                        if(abs(hf_av - hf_av_new) > 10) {\r
-                               DbpString("HF 13.56 Field Change:");\r
-                               DbpIntegers(hf_av,hf_av_new,hf_count);\r
-                               hf_av= hf_av_new;\r
+                               Dbprintf("HF 13.56 Field Change: %x %x %x", hf_av, hf_av_new, hf_count);\r
+                               hf_av = hf_av_new;\r
                                if (hf_av > hf_max)\r
                                        hf_max = hf_av;\r
                                hf_count= 0;\r
@@ -593,6 +605,12 @@ void UsbPacketReceived(BYTE *packet, int len)
                        break;\r
 #endif\r
 \r
+#ifdef WITH_ISO14443a\r
+               case CMD_READER_MIFARE:\r
+                       ReaderMifare(c->arg[0]);\r
+                       break;\r
+#endif\r
+      \r
 #ifdef WITH_ISO14443b\r
                case CMD_SNOOP_ISO_14443:\r
                        SnoopIso14443();\r
Impressum, Datenschutz