reworked debugger enabling
This commit is contained in:
parent
2376d14b5d
commit
5b41090add
@ -1,6 +1,6 @@
|
||||
#include "debugger.h"
|
||||
|
||||
Debugger_t debugger;
|
||||
DebugStatus_t DebuggerStatus[dbg_cntElements];
|
||||
|
||||
#ifdef FEATURE_ENABLE_REMOTE_DEBUG
|
||||
RemoteDebug Debug;
|
||||
@ -19,8 +19,8 @@ void RemoteDebug_dumpGlobals();
|
||||
|
||||
void initDebugger()
|
||||
{
|
||||
debugger.serial_debug_enabled = false;
|
||||
debugger.webui_live_debug_enabled = false;
|
||||
DebuggerStatus[dbg_Serial] = disabled;
|
||||
DebuggerStatus[dbg_Webui] = disabled;
|
||||
|
||||
Serial.setDebugOutput(false);
|
||||
|
||||
@ -45,27 +45,41 @@ void Debugger_Process()
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetDebugportStatus(DebugPorts_t port, DebugStatus_t status)
|
||||
{
|
||||
if (status == disabled)
|
||||
Debug_pushMessage("disable DebugPort %s", sDebugPorts[port]);
|
||||
|
||||
DebuggerStatus[port] = status;
|
||||
|
||||
if (status == enabled)
|
||||
Debug_pushMessage("enabled DebugPort %s", sDebugPorts[port]);
|
||||
}
|
||||
|
||||
void Debug_pushMessage(const char *format, ...)
|
||||
{
|
||||
if ((DebuggerStatus[dbg_Serial] == enabled) || (DebuggerStatus[dbg_Webui] == enabled))
|
||||
{
|
||||
char buff[64];
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
vsnprintf(buff, sizeof(buff), format, arg);
|
||||
va_end(arg);
|
||||
|
||||
if (debugger.serial_debug_enabled == true)
|
||||
if (DebuggerStatus[dbg_Serial] == enabled)
|
||||
{
|
||||
Serial.print(buff);
|
||||
}
|
||||
if (debugger.webui_live_debug_enabled == true)
|
||||
if (DebuggerStatus[dbg_Webui] == enabled)
|
||||
{
|
||||
Websocket_PushLiveDebug(String(buff));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pushCANDebug(uint32_t id, uint8_t dlc, uint8_t *data[])
|
||||
void pushCANDebug(uint32_t id, uint8_t dlc, uint8_t *data)
|
||||
{
|
||||
if (debugger.webui_live_debug_enabled == true)
|
||||
if ((DebuggerStatus[dbg_Serial] == enabled) || (DebuggerStatus[dbg_Webui] == enabled))
|
||||
{
|
||||
char buff[100];
|
||||
char *p = buff;
|
||||
@ -76,8 +90,16 @@ void pushCANDebug(uint32_t id, uint8_t dlc, uint8_t *data[])
|
||||
}
|
||||
*(p++) = '\n';
|
||||
*p = '\0';
|
||||
|
||||
if (DebuggerStatus[dbg_Serial] == enabled)
|
||||
{
|
||||
Serial.print(buff);
|
||||
}
|
||||
if (DebuggerStatus[dbg_Webui] == enabled)
|
||||
{
|
||||
Websocket_PushLiveDebug(String(buff));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEATURE_ENABLE_REMOTE_DEBUG
|
||||
|
@ -9,17 +9,28 @@
|
||||
#include "rmtdbghelp.h"
|
||||
#endif
|
||||
|
||||
typedef struct Debugger_s
|
||||
{
|
||||
bool webui_live_debug_enabled;
|
||||
bool serial_debug_enabled;
|
||||
} Debugger_t;
|
||||
typedef enum DebugStatus_e{
|
||||
enabled,
|
||||
disabled
|
||||
}DebugStatus_t;
|
||||
|
||||
extern Debugger_t debugger;
|
||||
typedef enum DebugPorts_e{
|
||||
dbg_Serial,
|
||||
dbg_Webui,
|
||||
dbg_cntElements
|
||||
}DebugPorts_t;
|
||||
|
||||
const char sDebugPorts[dbg_cntElements][7] = {
|
||||
"Serial",
|
||||
"WebUI"
|
||||
};
|
||||
|
||||
extern DebugStatus_t DebuggerStatus[dbg_cntElements];
|
||||
|
||||
void initDebugger();
|
||||
void Debugger_Process();
|
||||
void pushCANDebug(uint32_t id, uint8_t dlc, uint8_t *data[]);
|
||||
void pushCANDebug(uint32_t id, uint8_t dlc, uint8_t *data);
|
||||
void Debug_pushMessage(const char *format, ...);
|
||||
void SetDebugportStatus(DebugPorts_t port, DebugStatus_t status);
|
||||
|
||||
#endif
|
@ -552,13 +552,11 @@ void Websocket_HandleMessage(void *arg, uint8_t *data, size_t len)
|
||||
|
||||
if (strcmp((char *)data, "start") == 0)
|
||||
{
|
||||
Debug_pushMessage("Got WebSocket Message 'start' from client\n");
|
||||
debugger.webui_live_debug_enabled = true;
|
||||
SetDebugportStatus(dbg_Webui, enabled);
|
||||
}
|
||||
else if (strcmp((char *)data, "stop") == 0)
|
||||
{
|
||||
Debug_pushMessage("Got WebSocket Message 'stop' from client\n");
|
||||
debugger.webui_live_debug_enabled = false;
|
||||
SetDebugportStatus(dbg_Webui, disabled);
|
||||
}
|
||||
else if (strcmp((char *)data, "foo") == 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user