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.

This commit is contained in:
iceman1001 2016-03-06 10:35:25 +01:00
commit 38e4191705
4 changed files with 57 additions and 36 deletions

View file

@ -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");
}

View file

@ -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, "<samples to skip (10000)> <triggers to skip (1)> 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, "<samples to skip (10000)> <triggers to skip (1)> Generic LF/HF Snoop in Testing stage"},
{NULL, NULL, 0, NULL}
};

View file

@ -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;

View file

@ -13,8 +13,8 @@
#ifndef LFDEMOD_H__
#define LFDEMOD_H__
#include <stdint.h>
#include "common.h" //for bool
#include <stdint.h> // for uint_32+
#include <stdbool.h> // 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