From: iceman1001 Date: Sun, 6 Mar 2016 09:35:25 +0000 (+0100) Subject: CHG; a fix for "HF TUNE", I always were annoyed with the hf tune where it printed... X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/38e4191705fcf63696116c6663982f5b921ac2c1 CHG; a fix for "HF TUNE", I always were annoyed with the hf tune where it printed one value per row endlessly. So this fixes that, it uses "\r" to print on the same row. Works on MINGW/WINDOWS. Havn'nt tested it on Linux yet. But it looks good now. --- diff --git a/armsrc/appmain.c b/armsrc/appmain.c index cc074815..e2a1888e 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -80,16 +80,31 @@ void ToSendStuffBit(int b) { // Debug print functions, to go out over USB, to the usual PC-side client. //============================================================================= +void DbpStringEx(char *str, uint32_t cmd){ + byte_t len = strlen(str); + cmd_send(CMD_DEBUG_PRINT_STRING,len, cmd,0,(byte_t*)str,len); +} + void DbpString(char *str) { - byte_t len = strlen(str); - cmd_send(CMD_DEBUG_PRINT_STRING,len,0,0,(byte_t*)str,len); + DbpStringEx(str, 0); } #if 0 void DbpIntegers(int x1, int x2, int x3) { - cmd_send(CMD_DEBUG_PRINT_INTEGERS,x1,x2,x3,0,0); + cmd_send(CMD_DEBUG_PRINT_INTEGERS,x1,x2,x3,0,0); } #endif +void DbprintfEx(uint32_t cmd, const char *fmt, ...) { + // should probably limit size here; oh well, let's just use a big buffer + char output_string[128] = {0x00}; + va_list ap; + + va_start(ap, fmt); + kvsprintf(fmt, output_string, 10, ap); + va_end(ap); + + DbpStringEx(output_string, cmd); +} void Dbprintf(const char *fmt, ...) { // should probably limit size here; oh well, let's just use a big buffer @@ -229,23 +244,18 @@ void MeasureAntennaTuning(void) { void MeasureAntennaTuningHf(void) { int vHf = 0; // in mV - - DbpString("Measuring HF antenna, press button to exit"); - // Let the FPGA drive the high-frequency antenna around 13.56 MHz. FpgaDownloadAndGo(FPGA_BITSTREAM_HF); FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR); - for (;;) { + while ( !BUTTON_PRESS() ){ SpinDelay(20); vHf = (MAX_ADC_HF_VOLTAGE * AvgAdc(ADC_CHAN_HF)) >> 10; - - Dbprintf("%d mV",vHf); - if (BUTTON_PRESS()) break; + //Dbprintf("%d mV",vHf); + DbprintfEx(CMD_MEASURE_ANTENNA_TUNING_HF, "%d mV",vHf); } - - DbpString("cancelled"); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + DbpString("cancelled"); } diff --git a/client/cmdhf.c b/client/cmdhf.c index be842a34..969510df 100644 --- a/client/cmdhf.c +++ b/client/cmdhf.c @@ -31,9 +31,11 @@ static int CmdHelp(const char *Cmd); int CmdHFTune(const char *Cmd) { - UsbCommand c={CMD_MEASURE_ANTENNA_TUNING_HF}; - SendCommand(&c); - return 0; + PrintAndLog("Measuring HF antenna, press button to exit"); + UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING_HF}; + clearCommandBuffer(); + SendCommand(&c); + return 0; } @@ -644,6 +646,8 @@ int usage_hf_snoop(){ int CmdHFList(const char *Cmd) { + clearCommandBuffer(); + bool showWaitCycles = false; bool markCRCBytes = false; char type[10] = {0}; @@ -759,27 +763,27 @@ int CmdHFSnoop(const char *Cmd) int skiptriggers = param_get32ex(Cmd, 1, 0, 10); UsbCommand c = {CMD_HF_SNIFFER, {skippairs,skiptriggers,0}}; + clearCommandBuffer(); SendCommand(&c); return 0; } -static command_t CommandTable[] = -{ - {"help", CmdHelp, 1, "This help"}, - {"14a", CmdHF14A, 1, "{ ISO14443A RFIDs... }"}, - {"14b", CmdHF14B, 1, "{ ISO14443B RFIDs... }"}, - {"15", CmdHF15, 1, "{ ISO15693 RFIDs... }"}, - {"epa", CmdHFEPA, 1, "{ German Identification Card... }"}, - {"legic", CmdHFLegic, 0, "{ LEGIC RFIDs... }"}, - {"iclass", CmdHFiClass, 1, "{ ICLASS RFIDs... }"}, - {"mf", CmdHFMF, 1, "{ MIFARE RFIDs... }"}, - {"mfu", CmdHFMFUltra, 1, "{ MIFARE Ultralight RFIDs... }"}, - {"mfdes", CmdHFMFDes, 1, "{ MIFARE Desfire RFIDs... }"}, - {"topaz", CmdHFTopaz, 1, "{ TOPAZ (NFC Type 1) RFIDs... }"}, - {"tune", CmdHFTune, 0, "Continuously measure HF antenna tuning"}, - {"list", CmdHFList, 1, "List protocol data in trace buffer"}, - {"search", CmdHFSearch, 1, "Search for known HF tags [preliminary]"}, - {"snoop", CmdHFSnoop, 0, " Generic LF/HF Snoop in Testing stage"}, +static command_t CommandTable[] = { + {"help", CmdHelp, 1, "This help"}, + {"14a", CmdHF14A, 1, "{ ISO14443A RFIDs... }"}, + {"14b", CmdHF14B, 1, "{ ISO14443B RFIDs... }"}, + {"15", CmdHF15, 1, "{ ISO15693 RFIDs... }"}, + {"epa", CmdHFEPA, 1, "{ German Identification Card... }"}, + {"legic", CmdHFLegic, 0, "{ LEGIC RFIDs... }"}, + {"iclass", CmdHFiClass, 1, "{ ICLASS RFIDs... }"}, + {"mf", CmdHFMF, 1, "{ MIFARE RFIDs... }"}, + {"mfu", CmdHFMFUltra, 1, "{ MIFARE Ultralight RFIDs... }"}, + {"mfdes", CmdHFMFDes, 1, "{ MIFARE Desfire RFIDs... }"}, + {"topaz", CmdHFTopaz, 1, "{ TOPAZ (NFC Type 1) RFIDs... }"}, + {"tune", CmdHFTune, 0, "Continuously measure HF antenna tuning"}, + {"list", CmdHFList, 1, "List protocol data in trace buffer"}, + {"search", CmdHFSearch, 1, "Search for known HF tags [preliminary]"}, + {"snoop", CmdHFSnoop, 0, " Generic LF/HF Snoop in Testing stage"}, {NULL, NULL, 0, NULL} }; diff --git a/client/cmdmain.c b/client/cmdmain.c index 790a0c37..583bafca 100644 --- a/client/cmdmain.c +++ b/client/cmdmain.c @@ -185,7 +185,15 @@ void UsbCommandReceived(UsbCommand *UC) memset(s, 0x00, sizeof(s)); size_t len = MIN(UC->arg[0],USB_CMD_DATA_SIZE); memcpy(s, UC->d.asBytes, len); - PrintAndLog("#db# %s", s); + + // test + if ( UC->arg[1] == CMD_MEASURE_ANTENNA_TUNING_HF) { + printf("\r#db# %s", s); + fflush(stdout); + } + else + PrintAndLog("#db# %s", s); + return; } break; diff --git a/common/lfdemod.h b/common/lfdemod.h index d1a8e854..56c758ae 100644 --- a/common/lfdemod.h +++ b/common/lfdemod.h @@ -13,8 +13,8 @@ #ifndef LFDEMOD_H__ #define LFDEMOD_H__ -#include -#include "common.h" //for bool +#include // for uint_32+ +#include // for bool //generic size_t addParity(uint8_t *BitSource, uint8_t *dest, uint8_t sourceLen, uint8_t pLen, uint8_t pType); @@ -55,5 +55,4 @@ int ParadoxdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, ui int PyramiddemodFSK(uint8_t *dest, size_t *size); int VikingDemod_AM(uint8_t *dest, size_t *size); int PrescoDemod(uint8_t *dest, size_t *size); - #endif