mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -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
|
// emulator
|
||||||
case CMD_SET_DBGMODE: {
|
case CMD_SET_DBGMODE: {
|
||||||
g_dbglevel = packet->data.asBytes[0];
|
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);
|
reply_ng(CMD_SET_DBGMODE, PM3_SUCCESS, NULL, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "cmdhw.h"
|
#include "cmdhw.h"
|
||||||
#include "cmddata.h"
|
#include "cmddata.h"
|
||||||
#include "commonutil.h"
|
#include "commonutil.h"
|
||||||
|
#include "preferences.h"
|
||||||
#include "pm3_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
#include "pmflash.h" // rdv40validation_t
|
#include "pmflash.h" // rdv40validation_t
|
||||||
#include "cmdflashmem.h" // get_signature..
|
#include "cmdflashmem.h" // get_signature..
|
||||||
|
@ -476,14 +477,9 @@ static int CmdDbg(const char *Cmd) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCommandBuffer();
|
uint8_t curr = DBG_NONE;
|
||||||
SendCommandNG(CMD_GET_DBGMODE, NULL, 0);
|
if (getDeviceDebugLevel(&curr) != PM3_SUCCESS)
|
||||||
PacketResponseNG resp;
|
return PM3_EFAILED;
|
||||||
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];
|
|
||||||
|
|
||||||
const char *dbglvlstr;
|
const char *dbglvlstr;
|
||||||
switch (curr) {
|
switch (curr) {
|
||||||
|
@ -522,8 +518,8 @@ static int CmdDbg(const char *Cmd) {
|
||||||
else if (lv4)
|
else if (lv4)
|
||||||
dbg = 4;
|
dbg = 4;
|
||||||
|
|
||||||
clearCommandBuffer();
|
if (setDeviceDebugLevel(dbg, true) != PM3_SUCCESS)
|
||||||
SendCommandNG(CMD_SET_DBGMODE, &dbg, sizeof(dbg));
|
return PM3_EFAILED;
|
||||||
}
|
}
|
||||||
return PM3_SUCCESS;
|
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) {
|
static int setCmdOutput(const char *Cmd) {
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "prefs set output",
|
CLIParserInit(&ctx, "prefs set output",
|
||||||
|
|
|
@ -31,4 +31,7 @@ int preferences_save(void);
|
||||||
void preferences_save_callback(json_t *root);
|
void preferences_save_callback(json_t *root);
|
||||||
void preferences_load_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
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue