mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
set debug log level
This commit is contained in:
parent
af0e25b519
commit
ebe9d72cc2
4 changed files with 49 additions and 11 deletions
|
@ -799,7 +799,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
// emulator
|
||||
case CMD_SET_DBGMODE: {
|
||||
g_dbglevel = packet->data.asBytes[0];
|
||||
print_debug_level();
|
||||
if (packet->length == 1 || packet->data.asBytes[1] != 0)
|
||||
print_debug_level();
|
||||
reply_ng(CMD_SET_DBGMODE, PM3_SUCCESS, NULL, 0);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "cmdhw.h"
|
||||
#include "cmddata.h"
|
||||
#include "commonutil.h"
|
||||
#include "preferences.h"
|
||||
#include "pm3_cmd.h"
|
||||
#include "pmflash.h" // rdv40validation_t
|
||||
#include "cmdflashmem.h" // get_signature..
|
||||
|
@ -476,14 +477,9 @@ static int CmdDbg(const char *Cmd) {
|
|||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_GET_DBGMODE, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_GET_DBGMODE, &resp, 2000) == false) {
|
||||
PrintAndLogEx(WARNING, "Failed to get current device debug level");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
uint8_t curr = resp.data.asBytes[0];
|
||||
uint8_t curr = DBG_NONE;
|
||||
if (getDeviceDebugLevel(&curr) != PM3_SUCCESS)
|
||||
return PM3_EFAILED;
|
||||
|
||||
const char *dbglvlstr;
|
||||
switch (curr) {
|
||||
|
@ -522,8 +518,8 @@ static int CmdDbg(const char *Cmd) {
|
|||
else if (lv4)
|
||||
dbg = 4;
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_SET_DBGMODE, &dbg, sizeof(dbg));
|
||||
if (setDeviceDebugLevel(dbg, true) != PM3_SUCCESS)
|
||||
return PM3_EFAILED;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -762,6 +762,44 @@ static int setCmdDeviceDebug (const char *Cmd)
|
|||
}
|
||||
*/
|
||||
|
||||
int getDeviceDebugLevel (uint8_t *debug_level) {
|
||||
if (!g_session.pm3_present)
|
||||
return PM3_EFAILED;
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_GET_DBGMODE, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_GET_DBGMODE, &resp, 2000) == false) {
|
||||
PrintAndLogEx(WARNING, "Failed to get current device debug level");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if (debug_level)
|
||||
*debug_level = resp.data.asBytes[0];
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int setDeviceDebugLevel (uint8_t debug_level, bool verbose) {
|
||||
if (!g_session.pm3_present)
|
||||
return PM3_EFAILED;
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx (INFO,"setting device debug loglevel to %u", debug_level);
|
||||
|
||||
uint8_t cdata[] = {debug_level, verbose};
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_SET_DBGMODE, cdata, sizeof(cdata));
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_SET_DBGMODE, &resp, 2000) == false) {
|
||||
PrintAndLogEx (WARNING,"failed to set device debug loglevel");
|
||||
return PM3_EFAILED;
|
||||
}
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int setCmdOutput(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "prefs set output",
|
||||
|
|
|
@ -31,4 +31,7 @@ int preferences_save(void);
|
|||
void preferences_save_callback(json_t *root);
|
||||
void preferences_load_callback(json_t *root);
|
||||
|
||||
int getDeviceDebugLevel (uint8_t *debug_level);
|
||||
int setDeviceDebugLevel (uint8_t debug_level, bool verbose);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue