From 0248352ea6c9925356919239d57f947d7a877ead Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 21 Feb 2018 16:41:39 +0100 Subject: [PATCH] chg:simpler debug printing --- client/cmdlfawid.c | 6 +++--- client/cmdlfem4x.c | 6 +++--- client/cmdlfhid.c | 37 ++++++++++++++++++------------------- client/cmdlfhitag.c | 2 +- client/cmdlfindala.c | 9 ++++----- client/cmdlfindala.h | 3 +-- 6 files changed, 30 insertions(+), 33 deletions(-) diff --git a/client/cmdlfawid.c b/client/cmdlfawid.c index c0e465653..8b1205e52 100644 --- a/client/cmdlfawid.c +++ b/client/cmdlfawid.c @@ -362,10 +362,10 @@ int CmdAWIDDemod(const char *Cmd) { break; } - if (g_debugMode){ - PrintAndLogEx(DEBUG, "DEBUG: AWID idx: %d, Len: %d Printing Demod Buffer:", idx, size); + PrintAndLogEx(DEBUG, "DEBUG: AWID idx: %d, Len: %d Printing Demod Buffer:", idx, size); + if (g_debugMode) printDemodBuff(); - } + return 1; } diff --git a/client/cmdlfem4x.c b/client/cmdlfem4x.c index d19e09d34..6698a2661 100644 --- a/client/cmdlfem4x.c +++ b/client/cmdlfem4x.c @@ -939,7 +939,7 @@ int EM4x50Read(const char *Cmd, bool verbose) { AllPTest &= pTest; //get output Code[block] = OutputEM4x50_Block(DemodBuffer,DemodBufferLen,verbose, pTest); - if (g_debugMode) PrintAndLogEx(NORMAL, "\nskipping %d samples, bits:%d", skip, skip/clk); + PrintAndLogEx(DEBUG, "\nskipping %d samples, bits:%d", skip, skip/clk); //skip to start of next block snprintf(tmp,sizeof(tmp),"%i",skip); CmdLtrim(tmp); @@ -1076,11 +1076,11 @@ bool detectASK_MAN(){ bool detectASK_BI(){ int ans = ASKbiphaseDemod("0 0 1", false); if (!ans) { - if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/biphase normal demod failed"); + PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/biphase normal demod failed"); ans = ASKbiphaseDemod("0 1 1", false); if (!ans) { - if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/biphase inverted demod failed"); + PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/biphase inverted demod failed"); return false; } } diff --git a/client/cmdlfhid.c b/client/cmdlfhid.c index 4286cb62d..69567a3cb 100644 --- a/client/cmdlfhid.c +++ b/client/cmdlfhid.c @@ -138,21 +138,20 @@ int CmdHIDDemod(const char *Cmd) { int waveIdx = 0; int idx = HIDdemodFSK(bits, &size, &hi2, &hi, &lo, &waveIdx); if (idx < 0) { - if (g_debugMode){ - if (idx==-1){ - PrintAndLogEx(DEBUG, "DEBUG: Error - HID not enough samples"); - } else if (idx == -2) { - PrintAndLogEx(DEBUG, "DEBUG: Error - HID just noise detected"); - } else if (idx == -3) { - PrintAndLogEx(DEBUG, "DEBUG: Error - HID problem during FSK demod"); - } else if (idx == -4) { - PrintAndLogEx(DEBUG, "DEBUG: Error - HID preamble not found"); - } else if (idx == -5) { - PrintAndLogEx(DEBUG, "DEBUG: Error - HID error in Manchester data, size %d", size); - } else { - PrintAndLogEx(DEBUG, "DEBUG: Error - HID error demoding fsk %d", idx); - } - } + + if (idx == -1) + PrintAndLogEx(DEBUG, "DEBUG: Error - HID not enough samples"); + else if (idx == -2) + PrintAndLogEx(DEBUG, "DEBUG: Error - HID just noise detected"); + else if (idx == -3) + PrintAndLogEx(DEBUG, "DEBUG: Error - HID problem during FSK demod"); + else if (idx == -4) + PrintAndLogEx(DEBUG, "DEBUG: Error - HID preamble not found"); + else if (idx == -5) + PrintAndLogEx(DEBUG, "DEBUG: Error - HID error in Manchester data, size %d", size); + else + PrintAndLogEx(DEBUG, "DEBUG: Error - HID error demoding fsk %d", idx); + return 0; } @@ -160,7 +159,7 @@ int CmdHIDDemod(const char *Cmd) { setClockGrid(50, waveIdx + (idx*50)); if (hi2==0 && hi==0 && lo==0) { - if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - HID no values found"); + PrintAndLogEx(DEBUG, "DEBUG: Error - HID no values found"); return 0; } @@ -206,10 +205,10 @@ int CmdHIDDemod(const char *Cmd) { PrintAndLogEx(NORMAL, "HID Prox TAG ID: %x%08x (%u) - Format Len: %ubit - FC: %u - Card: %u", hi, lo, (lo>>1) & 0xFFFF, fmtLen, fc, cardnum); } - if (g_debugMode){ - PrintAndLogEx(DEBUG, "DEBUG: HID idx: %d, Len: %d, Printing Demod Buffer:", idx, size); + PrintAndLogEx(DEBUG, "DEBUG: HID idx: %d, Len: %d, Printing Demod Buffer:", idx, size); + if (g_debugMode) printDemodBuff(); - } + return 1; } diff --git a/client/cmdlfhitag.c b/client/cmdlfhitag.c index e75ab53cd..3e1bb08d1 100644 --- a/client/cmdlfhitag.c +++ b/client/cmdlfhitag.c @@ -256,7 +256,7 @@ int CmdLFHitagReader(const char *Cmd) { // Check the return status, stored in the first argument if (resp.arg[0] == false) { - if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - hitag failed"); + PrintAndLogEx(DEBUG, "DEBUG: Error - hitag failed"); return 1; } diff --git a/client/cmdlfindala.c b/client/cmdlfindala.c index 87d7b5d75..ab14638cd 100644 --- a/client/cmdlfindala.c +++ b/client/cmdlfindala.c @@ -121,7 +121,7 @@ int CmdIndalaDemod(const char *Cmd) { ans = PSKDemod("32", 0); if (!ans){ - if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Indala can't demod signal: %d",ans); + PrintAndLogEx(DEBUG, "DEBUG: Error - Indala can't demod signal: %d",ans); return 0; } @@ -134,8 +134,7 @@ int CmdIndalaDemod(const char *Cmd) { size = DemodBufferLen; idx = indala224decode(DemodBuffer, &size, &invert); if (idx < 0 || size != 224) { - if (g_debugMode) - PrintAndLogEx(DEBUG, "DEBUG: Error - Indala wrong size, expected [64|224] got: %d (startindex %i)", size, idx); + PrintAndLogEx(DEBUG, "DEBUG: Error - Indala wrong size, expected [64|224] got: %d (startindex %i)", size, idx); return -1; } } @@ -143,7 +142,7 @@ int CmdIndalaDemod(const char *Cmd) { setDemodBuf(DemodBuffer, size, (size_t)idx); setClockGrid(g_DemodClock, g_DemodStartIdx + (idx * g_DemodClock)); if (invert) { - if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Indala had to invert bits"); + PrintAndLogEx(DEBUG, "DEBUG: Error - Indala had to invert bits"); for (size_t i = 0; i < size; i++) DemodBuffer[i] ^= 1; } @@ -152,7 +151,7 @@ int CmdIndalaDemod(const char *Cmd) { uint32_t uid1, uid2, uid3, uid4, uid5, uid6, uid7; uid1 = bytebits_to_byte(DemodBuffer,32); uid2 = bytebits_to_byte(DemodBuffer+32,32); - if (DemodBufferLen==64){ + if (DemodBufferLen == 64){ PrintAndLogEx(SUCCESS, "Indala Found - Bitlength %d, UID = (%x%08x)\n%s", DemodBufferLen, uid1, uid2, sprint_bin_break(DemodBuffer,DemodBufferLen,32) ); diff --git a/client/cmdlfindala.h b/client/cmdlfindala.h index 705906cc9..73b41a13d 100644 --- a/client/cmdlfindala.h +++ b/client/cmdlfindala.h @@ -16,14 +16,13 @@ #include "proxmark3.h" // Definitions, USB controls, etc #include "ui.h" // PrintAndLog #include "cmdparser.h" // CmdsParse, CmdsHelp -#include "lfdemod.h" // parityTest +#include "lfdemod.h" // parityTest, bitbytes_to_byte #include "util.h" // weigandparity #include "protocols.h" // for T55xx config register definitions #include "data.h" #include "cmdmain.h" #include "cmddata.h" #include "cmdlf.h" // lf_read -#include "lfdemod.h" // bitbytes_to_byte extern int CmdLFINDALA(const char *Cmd);