chg:simpler debug printing

This commit is contained in:
iceman1001 2018-02-21 16:41:39 +01:00
parent e69ca55246
commit 0248352ea6
6 changed files with 30 additions and 33 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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