diff --git a/client/cmdcrc.c b/client/cmdcrc.c index 1c160dd63..7fd231763 100644 --- a/client/cmdcrc.c +++ b/client/cmdcrc.c @@ -435,14 +435,14 @@ int CmdrevengSearch(const char *Cmd){ if (ans) { // test for match if (memcmp(result, inCRC, crcChars) == 0){ - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(SUCCESS, "found possible match\nmodel: %s | value: %s\n", Models[i], result); + PrintAndLogEx(SUCCESS, "\nfound possible match\nmodel: %s | value: %s\n", Models[i], result); //optional - stop searching if found... found = true; } else { if (crcChars > 2){ char *swapEndian = SwapEndianStr(result, crcChars, crcChars); if (memcmp(swapEndian, inCRC, crcChars) == 0){ - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(SUCCESS, "found possible match\nmodel: %s | value endian swapped: %s\n", Models[i], swapEndian); + PrintAndLogEx(SUCCESS, "\nfound possible match\nmodel: %s | value endian swapped: %s\n", Models[i], swapEndian); // optional - stop searching if found... found = true; } @@ -454,14 +454,14 @@ int CmdrevengSearch(const char *Cmd){ if (ans) { // test for match if (memcmp(revResult, inCRC, crcChars) == 0){ - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(SUCCESS, "found possible match\nmodel reversed: %s | value: %s\n", Models[i], revResult); + PrintAndLogEx(SUCCESS, "\nfound possible match\nmodel reversed: %s | value: %s\n", Models[i], revResult); // optional - stop searching if found... found = true; } else { if (crcChars > 2){ char *swapEndian = SwapEndianStr(revResult, crcChars, crcChars); if (memcmp(swapEndian, inCRC, crcChars) == 0){ - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(SUCCESS, "found possible match\nmodel reversed: %s | value endian swapped: %s\n", Models[i], swapEndian); + PrintAndLogEx(SUCCESS, "\nfound possible match\nmodel reversed: %s | value endian swapped: %s\n", Models[i], swapEndian); // optional - stop searching if found... found = true; } diff --git a/client/cmddata.c b/client/cmddata.c index 285223243..75bf84ba1 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -1416,7 +1416,7 @@ int getSamples(int n, bool silent) { UsbCommand response; if ( !WaitForResponseTimeout(CMD_ACK, &response, 10000) ) { - PrintAndLogEx(NORMAL, "timeout while waiting for reply."); + PrintAndLogEx(WARNING, "timeout while waiting for reply."); return 1; } @@ -1472,7 +1472,7 @@ int CmdTuneSamples(const char *Cmd) { #define HF_MARGINAL_V 5000 #define ANTENNA_ERROR 1.03 // current algo has 3% error margin. int timeout = 0; - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(SUCCESS, "measuring antenna characteristics, please wait..."); + PrintAndLogEx(INFO, "\nmeasuring antenna characteristics, please wait..."); UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING, {0,0,0}}; clearCommandBuffer(); @@ -1482,7 +1482,7 @@ int CmdTuneSamples(const char *Cmd) { timeout++; printf("."); fflush(stdout); if (timeout > 7) { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "no response from Proxmark. Aborting..."); + PrintAndLogEx(WARNING, "\nno response from Proxmark. Aborting..."); return 1; } } diff --git a/client/cmdhf14a.c b/client/cmdhf14a.c index e4e5abe8a..c09703bbc 100644 --- a/client/cmdhf14a.c +++ b/client/cmdhf14a.c @@ -1002,7 +1002,7 @@ static int waitCmd(uint8_t iSelect) { PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.d.asBytes, len) ); } else { - PrintAndLogEx(NORMAL, "timeout while waiting for reply."); + PrintAndLogEx(WARNING, "timeout while waiting for reply."); return 3; } return 0; diff --git a/client/cmdhf14b.c b/client/cmdhf14b.c index 29e4e4e46..7dda64a61 100644 --- a/client/cmdhf14b.c +++ b/client/cmdhf14b.c @@ -553,7 +553,7 @@ bool HF14B_Other_Reader(){ // WaitForResponse(CMD_ACK,&resp); // if (datalen > 2 ) { - // PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(NORMAL, "14443-3b tag found:"); + // PrintAndLogEx(NORMAL, "\n14443-3b tag found:"); // PrintAndLogEx(NORMAL, "unknown tag type answered to a 0x000b3f80 command ans:"); // //PrintAndLogEx(NORMAL, "%s", sprint_hex(data, datalen)); // rawclose(); @@ -568,7 +568,7 @@ bool HF14B_Other_Reader(){ // WaitForResponse(CMD_ACK, &resp); // if (datalen > 0) { - // PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(NORMAL, "14443-3b tag found:"); + // PrintAndLogEx(NORMAL, "\n14443-3b tag found:"); // PrintAndLogEx(NORMAL, "Unknown tag type answered to a 0x0A command ans:"); // // PrintAndLogEx(NORMAL, "%s", sprint_hex(data, datalen)); // rawClose(); @@ -583,7 +583,7 @@ bool HF14B_Other_Reader(){ // WaitForResponse(CMD_ACK, &resp); // if (datalen > 0) { - // PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(NORMAL, "14443-3b tag found:"); + // PrintAndLogEx(NORMAL, "\n14443-3b tag found:"); // PrintAndLogEx(NORMAL, "Unknown tag type answered to a 0x0C command ans:"); // PrintAndLogEx(NORMAL, "%s", sprint_hex(data, datalen)); // rawClose(); diff --git a/client/cmdhf15.c b/client/cmdhf15.c index 1b4c719ff..e799f3c23 100644 --- a/client/cmdhf15.c +++ b/client/cmdhf15.c @@ -220,7 +220,7 @@ int getUID(uint8_t *buf) { } // retry if ( retry >= 3 ) - PrintAndLogEx(FAILED, "timeout while waiting for reply."); + PrintAndLogEx(WARNING, "timeout while waiting for reply."); return 0; } @@ -956,7 +956,7 @@ int CmdHF15Raw(const char *Cmd) { PrintAndLogEx(NORMAL, "received %i octets", len); PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.d.asBytes, len) ); } else { - PrintAndLogEx(FAILED, "timeout while waiting for reply."); + PrintAndLogEx(WARNING, "timeout while waiting for reply."); } } return 0; diff --git a/client/cmdhffelica.c b/client/cmdhffelica.c index 40809954d..74960bf9c 100644 --- a/client/cmdhffelica.c +++ b/client/cmdhffelica.c @@ -377,7 +377,7 @@ int CmdHFFelicaDumpLite(const char *Cmd) { } } if (resp.arg[0] == 0) { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "Button pressed. Aborted."); + PrintAndLogEx(WARNING, "\nButton pressed. Aborted."); return 1; } diff --git a/client/cmdhficlass.c b/client/cmdhficlass.c index 557a87359..96284051f 100644 --- a/client/cmdhficlass.c +++ b/client/cmdhficlass.c @@ -386,11 +386,11 @@ int CmdHFiClassSim(const char *Cmd) { tries++; if (ukbhit()) { int gc = getchar(); (void)gc; - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "aborted via keyboard."); + PrintAndLogEx(WARNING, "\naborted via keyboard."); return 0; } if ( tries > 20) { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "timeout while waiting for reply."); + PrintAndLogEx(WARNING, "\ntimeout while waiting for reply."); return 0; } } @@ -438,11 +438,11 @@ int CmdHFiClassSim(const char *Cmd) { tries++; if (ukbhit()) { int gc = getchar(); (void)gc; - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "aborted via keyboard."); + PrintAndLogEx(WARNING, "\naborted via keyboard."); return 0; } if ( tries > 20) { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "timeout while waiting for reply."); + PrintAndLogEx(WARNING, "\ntimeout while waiting for reply."); return 0; } } @@ -924,11 +924,11 @@ int CmdHFiClassReader_Dump(const char *Cmd) { if (keyNbr < ICLASS_KEYS_MAX) { memcpy(CreditKEY, iClass_Key_Table[keyNbr], 8); } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit KeyNbr is invalid\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit KeyNbr is invalid\n"); errors = true; } } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit Key is incorrect length\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit Key is incorrect length\n"); errors = true; } cmdp += 2; @@ -958,11 +958,11 @@ int CmdHFiClassReader_Dump(const char *Cmd) { if (keyNbr < ICLASS_KEYS_MAX) { memcpy(KEY, iClass_Key_Table[keyNbr], 8); } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit KeyNbr is invalid\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit KeyNbr is invalid\n"); errors = true; } } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit Key is incorrect length\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit Key is incorrect length\n"); errors = true; } cmdp += 2; @@ -1219,11 +1219,11 @@ int CmdHFiClass_WriteBlock(const char *Cmd) { if (keyNbr < ICLASS_KEYS_MAX) { memcpy(KEY, iClass_Key_Table[keyNbr], 8); } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit KeyNbr is invalid\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit KeyNbr is invalid\n"); errors = true; } } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit Key is incorrect length\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit Key is incorrect length\n"); errors = true; } cmdp += 2; @@ -1308,11 +1308,11 @@ int CmdHFiClassCloneTag(const char *Cmd) { if (keyNbr < ICLASS_KEYS_MAX) { memcpy(KEY, iClass_Key_Table[keyNbr], 8); } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit KeyNbr is invalid\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit KeyNbr is invalid\n"); errors = true; } } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit Key is incorrect length\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit Key is incorrect length\n"); errors = true; } cmdp += 2; @@ -1493,11 +1493,11 @@ int CmdHFiClass_ReadBlock(const char *Cmd) { if (keyNbr < ICLASS_KEYS_MAX) { memcpy(KEY, iClass_Key_Table[keyNbr], 8); } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit KeyNbr is invalid\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit KeyNbr is invalid\n"); errors = true; } } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit Key is incorrect length\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit Key is incorrect length\n"); errors = true; } cmdp += 2; @@ -1709,11 +1709,11 @@ int CmdHFiClassCalcNewKey(const char *Cmd) { if (keyNbr < ICLASS_KEYS_MAX) { memcpy(NEWKEY, iClass_Key_Table[keyNbr], 8); } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: NewKey Nbr is invalid\n"); + PrintAndLogEx(WARNING, "\nERROR: NewKey Nbr is invalid\n"); errors = true; } } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: NewKey is incorrect length\n"); + PrintAndLogEx(WARNING, "\nERROR: NewKey is incorrect length\n"); errors = true; } cmdp += 2; @@ -1728,11 +1728,11 @@ int CmdHFiClassCalcNewKey(const char *Cmd) { if (keyNbr < ICLASS_KEYS_MAX) { memcpy(OLDKEY, iClass_Key_Table[keyNbr], 8); } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit KeyNbr is invalid\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit KeyNbr is invalid\n"); errors = true; } } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Credit Key is incorrect length\n"); + PrintAndLogEx(WARNING, "\nERROR: Credit Key is incorrect length\n"); errors = true; } cmdp += 2; @@ -1861,7 +1861,7 @@ int CmdHFiClassManageKeys(const char *Cmd) { if (dataLen == 16) { //ul-c or ev1/ntag key length errors = param_gethex(tempStr, 0, KEY, dataLen); } else { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "ERROR: Key is incorrect length\n"); + PrintAndLogEx(WARNING, "\nERROR: Key is incorrect length\n"); errors = true; } cmdp += 2; @@ -1979,7 +1979,7 @@ int CmdHFiClassCheckKeys(const char *Cmd) { if (select_only(CSN, CCNR, false, false)) { got_csn = true; } else { - PrintAndLogEx(NORMAL, "[-] one more try\n"); + PrintAndLogEx(WARNING, "one more try\n"); } } @@ -2045,7 +2045,7 @@ int CmdHFiClassCheckKeys(const char *Cmd) { timeout++; printf("."); fflush(stdout); if (timeout > 120) { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(WARNING, "no response from Proxmark. Aborting..."); + PrintAndLogEx(WARNING, "\nno response from Proxmark. Aborting..."); goto out; } } @@ -2087,7 +2087,7 @@ int CmdHFiClassCheckKeys(const char *Cmd) { out: t1 = msclock() - t1; - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(SUCCESS, "Time in iclass checkkeys: %.0f seconds\n", (float)t1/1000.0); + PrintAndLogEx(SUCCESS, "\nTime in iclass checkkeys: %.0f seconds\n", (float)t1/1000.0); DropField(); free(pre); @@ -2245,7 +2245,7 @@ int CmdHFiClassLookUp(const char *Cmd) { // using find item = (iclass_prekey_t*) bsearch(&lookup, prekey, keycnt, sizeof(iclass_prekey_t), cmp_uint32); if( item != NULL ) { - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(SUCCESS, "[debit] found key %s", sprint_hex(item->key, 8)); + PrintAndLogEx(SUCCESS, "\n[debit] found key %s", sprint_hex(item->key, 8)); } t1 = msclock() - t1; diff --git a/client/cmdlfhitag.c b/client/cmdlfhitag.c index 8cf9c44fe..d248a2133 100644 --- a/client/cmdlfhitag.c +++ b/client/cmdlfhitag.c @@ -251,7 +251,7 @@ int CmdLFHitagReader(const char *Cmd) { SendCommand(&c); UsbCommand resp; if ( !WaitForResponseTimeout(CMD_ACK, &resp, 4000) ) { - PrintAndLogEx(NORMAL, "timeout while waiting for reply."); + PrintAndLogEx(WARNING, "timeout while waiting for reply."); return 1; } diff --git a/client/cmdmain.c b/client/cmdmain.c index 1e93e9b91..f414cbf3b 100644 --- a/client/cmdmain.c +++ b/client/cmdmain.c @@ -208,7 +208,7 @@ void UsbCommandReceived(UsbCommand* _ch) { char s[USB_CMD_DATA_SIZE+1]; memset(s, 0x00, sizeof(s)); - size_t len = MIN(c->arg[0],USB_CMD_DATA_SIZE); + size_t len = MIN(c->arg[0], USB_CMD_DATA_SIZE); memcpy(s, c->d.asBytes, len); // print debug line on same row. escape seq \r @@ -233,11 +233,10 @@ void UsbCommandReceived(UsbCommand* _ch) { // arg1 = length bytes to transfer // arg2 = bigbuff tracelength (?) uint32_t offset = c->arg[0]; - uint32_t len = c->arg[1]; + uint32_t len = MIN(c->arg[1], sample_buf_size); //uint32_t tracelen = c->arg[2]; - // extra bounds check. - len = MIN(sample_buf_size, len); + printf("SAMPLE_BUF_SIZE %u | adjusted len %u \n", sample_buf_size, len); memcpy( sample_buf + offset, c->d.asBytes, len); //PrintAndLogEx(NORMAL, "ICE:: Download from device. chunk %" PRIu32 " | size %" PRIu32 " | tracelen:%" PRIu32 " \n", offset, len, c->arg[2]); diff --git a/client/cmdscript.c b/client/cmdscript.c index 33d88b5cc..ed587341c 100644 --- a/client/cmdscript.c +++ b/client/cmdscript.c @@ -162,7 +162,7 @@ int CmdScriptRun(const char *Cmd) { //luaL_dofile(lua_state, buf); // close the Lua state lua_close(lua_state); - PrintAndLogEx(NORMAL, "\n"); PrintAndLogEx(SUCCESS, "Finished\n"); + PrintAndLogEx(SUCCESS, "\nFinished\n"); return 0; } diff --git a/client/cmdtrace.c b/client/cmdtrace.c index da948fcc5..5c47b7dc2 100644 --- a/client/cmdtrace.c +++ b/client/cmdtrace.c @@ -489,7 +489,7 @@ int CmdTraceList(const char *Cmd) { UsbCommand response; GetFromBigBuf(trace, USB_CMD_DATA_SIZE, 0); if ( !WaitForResponseTimeout(CMD_ACK, &response, 4000) ) { - PrintAndLogEx(FAILED, "timeout while waiting for reply."); + PrintAndLogEx(WARNING, "timeout while waiting for reply."); return 1; } diff --git a/client/ui.c b/client/ui.c index f7977c0ed..a0c1b9b59 100644 --- a/client/ui.c +++ b/client/ui.c @@ -87,17 +87,25 @@ void PrintAndLogEx(logLevel_t level, char *fmt, ...) { } if (strchr(buffer, '\n')) { + + const char delim[2] = "\n"; - token = strtok(buffer, "\n"); + // line starts with newline + if (buffer[0] == '\n') + PrintAndLog(""); + + token = strtok(buffer, delim); while (token != NULL) { + size = strlen(buffer2); + if (strlen(token)) snprintf(buffer2+size, sizeof(buffer2)-size, "%s%s\n", prefix, token); else snprintf(buffer2+size, sizeof(buffer2)-size, "\n"); - token = strtok(NULL, "\n"); + token = strtok(NULL, delim); } PrintAndLog(buffer2); } else {