mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-12-25 01:21:52 +08:00
simpler debug
This commit is contained in:
parent
0248352ea6
commit
db6b1bab7d
5 changed files with 51 additions and 62 deletions
|
@ -110,7 +110,7 @@ int CmdPyramidDemod(const char *Cmd) {
|
|||
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
|
||||
uint8_t bits[MAX_GRAPH_TRACE_LEN]={0};
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
if (size==0) {
|
||||
if (size == 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid not enough samples");
|
||||
return 0;
|
||||
}
|
||||
|
@ -118,20 +118,18 @@ int CmdPyramidDemod(const char *Cmd) {
|
|||
int waveIdx=0;
|
||||
int idx = detectPyramid(bits, &size, &waveIdx);
|
||||
if (idx < 0){
|
||||
if (g_debugMode){
|
||||
if (idx == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: not enough samples");
|
||||
else if (idx == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: only noise found");
|
||||
else if (idx == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: problem during FSK demod");
|
||||
else if (idx == -4)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: preamble not found");
|
||||
else if (idx == -5)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: error demoding fsk idx: %d",idx);
|
||||
}
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: not enough samples");
|
||||
else if (idx == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: only noise found");
|
||||
else if (idx == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: problem during FSK demod");
|
||||
else if (idx == -4)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: preamble not found");
|
||||
else if (idx == -5)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: error demoding fsk idx: %d",idx);
|
||||
return 0;
|
||||
}
|
||||
setDemodBuf(bits, size, idx);
|
||||
|
@ -176,12 +174,10 @@ int CmdPyramidDemod(const char *Cmd) {
|
|||
|
||||
size = removeParity(bits, idx+8, 8, 1, 120);
|
||||
if (size != 105){
|
||||
if (g_debugMode) {
|
||||
if ( size == 0)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: parity check failed - IDX: %d, hi3: %08X", idx, rawHi3);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: at parity check - tag size does not match Pyramid format, SIZE: %d, IDX: %d, hi3: %08X", size, idx, rawHi3);
|
||||
}
|
||||
if ( size == 0)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: parity check failed - IDX: %d, hi3: %08X", idx, rawHi3);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: at parity check - tag size does not match Pyramid format, SIZE: %d, IDX: %d, hi3: %08X", size, idx, rawHi3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -245,10 +241,10 @@ int CmdPyramidDemod(const char *Cmd) {
|
|||
else
|
||||
PrintAndLogEx(FAILED, "Checksum %02x failed - should have been %02x", checksum, checkCS);
|
||||
|
||||
if (g_debugMode){
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Pyramid: idx: %d, Len: %d, Printing Demod Buffer:", idx, 128);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Pyramid: idx: %d, Len: %d, Printing Demod Buffer:", idx, 128);
|
||||
if (g_debugMode)
|
||||
printDemodBuff();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,23 +30,21 @@ int CmdSecurakeyDemod(const char *Cmd) {
|
|||
//ASK / Manchester
|
||||
bool st = false;
|
||||
if (!ASKDemod_ext("40 0 0", false, false, 1, &st)) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: ASK/Manchester Demod failed");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: ASK/Manchester Demod failed");
|
||||
return 0;
|
||||
}
|
||||
if (st) return 0;
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectSecurakey(DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (g_debugMode) {
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: too few bits found");
|
||||
else if (ans == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: preamble not found");
|
||||
else if (ans == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: Size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: ans: %d", ans);
|
||||
}
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: too few bits found");
|
||||
else if (ans == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: preamble not found");
|
||||
else if (ans == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: Size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Securakey: ans: %d", ans);
|
||||
return 0;
|
||||
}
|
||||
setDemodBuf(DemodBuffer, 96, ans);
|
||||
|
@ -75,14 +73,14 @@ int CmdSecurakeyDemod(const char *Cmd) {
|
|||
// remove marker bits (0's every 9th digit after preamble) (pType = 3 (always 0s))
|
||||
size = removeParity(bits_no_spacer, 0, 9, 3, 85);
|
||||
if ( size != 85-9 ) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error removeParity: %d", size);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error removeParity: %d", size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t bitLen = (uint8_t)bytebits_to_byte(bits_no_spacer+2, 6);
|
||||
uint32_t fc=0, lWiegand=0, rWiegand=0;
|
||||
if (bitLen > 40) { //securakey's max bitlen is 40 bits...
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error bitLen too long: %u", bitLen);
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error bitLen too long: %u", bitLen);
|
||||
return 0;
|
||||
}
|
||||
// get left 1/2 wiegand & right 1/2 wiegand (for parity test and wiegand print)
|
||||
|
|
|
@ -73,14 +73,14 @@ int detectViking(uint8_t *dest, size_t *size) {
|
|||
//see ASKDemod for what args are accepted
|
||||
int CmdVikingDemod(const char *Cmd) {
|
||||
if (!ASKDemod(Cmd, false, false, 1)) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Viking ASKDemod failed");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Viking ASKDemod failed");
|
||||
return 0;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
|
||||
int ans = detectViking(DemodBuffer, &size);
|
||||
if (ans < 0) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Viking Demod %d %s", ans, (ans == -5)?"[chksum error]":"");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Viking Demod %d %s", ans, (ans == -5)?"[chksum error]":"");
|
||||
return 0;
|
||||
}
|
||||
//got a good demod
|
||||
|
|
|
@ -104,23 +104,22 @@ int CmdVisa2kDemod(const char *Cmd) {
|
|||
//ASK / Manchester
|
||||
bool st = true;
|
||||
if (!ASKDemod_ext("64 0 0", false, false, 1, &st)) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ASK/Manchester Demod failed");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ASK/Manchester Demod failed");
|
||||
save_restoreGB(0);
|
||||
return 0;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectVisa2k(DemodBuffer, &size);
|
||||
if (ans < 0){
|
||||
if (g_debugMode){
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: too few bits found");
|
||||
else if (ans == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: preamble not found");
|
||||
else if (ans == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: Size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ans: %d", ans);
|
||||
}
|
||||
if (ans == -1)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: too few bits found");
|
||||
else if (ans == -2)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: preamble not found");
|
||||
else if (ans == -3)
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: Size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Visa2k: ans: %d", ans);
|
||||
|
||||
save_restoreGB(0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -105,8 +105,7 @@ int GetAskClock(const char *str, bool printAns) {
|
|||
uint8_t grph[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
size_t size = getFromGraphBuf(grph);
|
||||
if (size == 0) {
|
||||
if (g_debugMode)
|
||||
PrintAndLogEx(WARNING, "Failed to copy from graphbuffer");
|
||||
PrintAndLogEx(WARNING, "Failed to copy from graphbuffer");
|
||||
return -1;
|
||||
}
|
||||
//, size_t *ststart, size_t *stend
|
||||
|
@ -129,8 +128,7 @@ uint8_t GetPskCarrier(const char *str, bool printAns) {
|
|||
uint8_t grph[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
size_t size = getFromGraphBuf(grph);
|
||||
if ( size == 0 ) {
|
||||
if (g_debugMode)
|
||||
PrintAndLogEx(WARNING, "Failed to copy from graphbuffer");
|
||||
PrintAndLogEx(WARNING, "Failed to copy from graphbuffer");
|
||||
return 0;
|
||||
}
|
||||
uint16_t fc = countFC(grph, size, 0);
|
||||
|
@ -152,7 +150,7 @@ int GetPskClock(const char* str, bool printAns) {
|
|||
uint8_t grph[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
size_t size = getFromGraphBuf(grph);
|
||||
if ( size == 0 ) {
|
||||
if (g_debugMode) PrintAndLogEx(WARNING, "Failed to copy from graphbuffer");
|
||||
PrintAndLogEx(WARNING, "Failed to copy from graphbuffer");
|
||||
return -1;
|
||||
}
|
||||
size_t firstPhaseShiftLoc = 0;
|
||||
|
@ -175,8 +173,7 @@ int GetNrzClock(const char* str, bool printAns) {
|
|||
uint8_t grph[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
size_t size = getFromGraphBuf(grph);
|
||||
if ( size == 0 ) {
|
||||
if (g_debugMode)
|
||||
PrintAndLogEx(WARNING, "Failed to copy from graphbuffer");
|
||||
PrintAndLogEx(WARNING, "Failed to copy from graphbuffer");
|
||||
return -1;
|
||||
}
|
||||
size_t clkStartIdx = 0;
|
||||
|
@ -206,10 +203,9 @@ int GetFskClock(const char* str, bool printAns) {
|
|||
setClockGrid(rf1, firstClockEdge);
|
||||
return rf1;
|
||||
}
|
||||
if (g_debugMode) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: unknown fsk field clock detected");
|
||||
PrintAndLogEx(NORMAL, "Detected Field Clocks: FC/%d, FC/%d - Bit Clock: RF/%d", fc1, fc2, rf1);
|
||||
}
|
||||
|
||||
PrintAndLogEx(DEBUG, "DEBUG: unknown fsk field clock detected");
|
||||
PrintAndLogEx(DEBUG, "Detected Field Clocks: FC/%d, FC/%d - Bit Clock: RF/%d", fc1, fc2, rf1);
|
||||
return 0;
|
||||
}
|
||||
int fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge) {
|
||||
|
@ -220,7 +216,7 @@ int fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge) {
|
|||
|
||||
uint16_t ans = countFC(bits, size, 1);
|
||||
if (ans == 0) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: No data found");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: No data found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -229,7 +225,7 @@ int fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge) {
|
|||
//int firstClockEdge = 0;
|
||||
*rf1 = detectFSKClk(bits, size, *fc1, *fc2, firstClockEdge);
|
||||
if (*rf1 == 0) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Clock detect error");
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Clock detect error");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue