// 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
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");
}
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;
}
int CmdHFList(const char *Cmd)
{
+ clearCommandBuffer();
+
bool showWaitCycles = false;
bool markCRCBytes = false;
char type[10] = {0};
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}
};