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