reworked debugger enabling

This commit is contained in:
2023-02-24 00:05:51 +01:00
parent 2376d14b5d
commit 5b41090add
3 changed files with 60 additions and 29 deletions

View File

@@ -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, ...)
{
char buff[64];
va_list arg;
va_start(arg, format);
vsnprintf(buff, sizeof(buff), format, arg);
va_end(arg);
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)
{
Serial.print(buff);
}
if (debugger.webui_live_debug_enabled == true)
{
Websocket_PushLiveDebug(String(buff));
if (DebuggerStatus[dbg_Serial] == enabled)
{
Serial.print(buff);
}
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,7 +90,15 @@ void pushCANDebug(uint32_t id, uint8_t dlc, uint8_t *data[])
}
*(p++) = '\n';
*p = '\0';
Websocket_PushLiveDebug(String(buff));
if (DebuggerStatus[dbg_Serial] == enabled)
{
Serial.print(buff);
}
if (DebuggerStatus[dbg_Webui] == enabled)
{
Websocket_PushLiveDebug(String(buff));
}
}
}