mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-23 00:21:53 +08:00
chg: made debugprintig easier.
This commit is contained in:
parent
a29b2328db
commit
7064a2dd71
1 changed files with 36 additions and 39 deletions
|
@ -10,7 +10,7 @@
|
|||
#include "cmddata.h"
|
||||
|
||||
uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
uint8_t g_debugMode = 0;
|
||||
//uint8_t g_debugMode = 0;
|
||||
size_t DemodBufferLen = 0;
|
||||
size_t g_DemodStartIdx = 0;
|
||||
int g_DemodClock = 0;
|
||||
|
@ -476,7 +476,7 @@ int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType,
|
|||
|
||||
size_t BitLen = getFromGraphBuf(BitStream);
|
||||
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) Bitlen from grphbuff: %d", BitLen);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) Bitlen from grphbuff: %d", BitLen);
|
||||
|
||||
if (BitLen < 255) return 0;
|
||||
|
||||
|
@ -505,13 +505,11 @@ int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType,
|
|||
int errCnt = askdemod_ext(BitStream, &BitLen, &clk, &invert, maxErr, askamp, askType, &startIdx);
|
||||
|
||||
if (errCnt < 0 || BitLen < 16){ //if fatal error (or -1)
|
||||
if (g_debugMode)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) No data found errors:%d, invert:%d, bitlen:%d, clock:%d", errCnt, invert, BitLen, clk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (errCnt > maxErr){
|
||||
if (g_debugMode)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) Too many errors found, errors:%d, bits:%d, clock:%d", errCnt, BitLen, clk);
|
||||
return 0;
|
||||
}
|
||||
|
@ -667,14 +665,14 @@ int ASKbiphaseDemod(const char *Cmd, bool verbose)
|
|||
uint8_t BitStream[MAX_DEMOD_BUF_LEN];
|
||||
size_t size = getFromGraphBuf(BitStream);
|
||||
if (size == 0 ) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: no data in graphbuf");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: no data in graphbuf");
|
||||
return 0;
|
||||
}
|
||||
int startIdx = 0;
|
||||
//invert here inverts the ask raw demoded bits which has no effect on the demod, but we need the pointer
|
||||
int errCnt = askdemod_ext(BitStream, &size, &clk, &invert, maxErr, 0, 0, &startIdx);
|
||||
if ( errCnt < 0 || errCnt > maxErr ) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: no data or error found %d, clock: %d", errCnt, clk);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: no data or error found %d, clock: %d", errCnt, clk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1100,7 @@ int PSKDemod(const char *Cmd, bool verbose)
|
|||
int CmdPSKIdteck(const char *Cmd) {
|
||||
|
||||
if (!PSKDemod("", false)) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
return 0;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
|
@ -1110,7 +1108,7 @@ int CmdPSKIdteck(const char *Cmd) {
|
|||
//get binary from PSK1 wave
|
||||
int idx = detectIdteck(DemodBuffer, &size);
|
||||
if (idx < 0){
|
||||
if (g_debugMode){
|
||||
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: not enough samples");
|
||||
else if (idx == -2)
|
||||
|
@ -1119,16 +1117,15 @@ int CmdPSKIdteck(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: idx: %d",idx);
|
||||
}
|
||||
|
||||
// if didn't find preamble try again inverting
|
||||
if (!PSKDemod("1", false)) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck PSKDemod failed");
|
||||
return 0;
|
||||
}
|
||||
idx = detectIdteck(DemodBuffer, &size);
|
||||
if (idx < 0){
|
||||
if (g_debugMode){
|
||||
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: not enough samples");
|
||||
else if (idx == -2)
|
||||
|
@ -1137,7 +1134,7 @@ int CmdPSKIdteck(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Idteck: idx: %d",idx);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1181,11 +1178,11 @@ int NRZrawDemod(const char *Cmd, bool verbose)
|
|||
int clkStartIdx = 0;
|
||||
errCnt = nrzRawDemod(BitStream, &BitLen, &clk, &invert, &clkStartIdx);
|
||||
if (errCnt > maxErr){
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: (NRZrawDemod) Too many errors found, clk: %d, invert: %d, numbits: %d, errCnt: %d",clk,invert,BitLen,errCnt);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: (NRZrawDemod) Too many errors found, clk: %d, invert: %d, numbits: %d, errCnt: %d",clk,invert,BitLen,errCnt);
|
||||
return 0;
|
||||
}
|
||||
if (errCnt<0 || BitLen<16){ //throw away static - allow 1 and -1 (in case of threshold command first)
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: (NRZrawDemod) no data found, clk: %d, invert: %d, numbits: %d, errCnt: %d",clk,invert,BitLen,errCnt);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: (NRZrawDemod) no data found, clk: %d, invert: %d, numbits: %d, errCnt: %d",clk,invert,BitLen,errCnt);
|
||||
return 0;
|
||||
}
|
||||
if (verbose || g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: (NRZrawDemod) Tried NRZ Demod using Clock: %d - invert: %d - Bits Found: %d",clk,invert,BitLen);
|
||||
|
@ -1286,7 +1283,7 @@ int CmdRawDemod(const char *Cmd)
|
|||
void setClockGrid(int clk, int offset) {
|
||||
g_DemodStartIdx = offset;
|
||||
g_DemodClock = clk;
|
||||
if (g_debugMode) PrintAndLogEx(NORMAL, "DBEUG: (setClockGrid) demodoffset %d, clk %d",offset,clk);
|
||||
PrintAndLogEx(DEBUG, "DBEUG: (setClockGrid) demodoffset %d, clk %d",offset,clk);
|
||||
|
||||
if (offset > clk) offset %= clk;
|
||||
if (offset < 0) offset += clk;
|
||||
|
|
Loading…
Reference in a new issue