mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-21 23:35:30 +03:00
Implement ASSERT() to make debugging easier (#476)
* Initial cut of ASSERT() implementation
This commit is contained in:
parent
5b8b9781da
commit
e1d8b5eee9
8 changed files with 137 additions and 1 deletions
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "build/version.h"
|
||||
#include "build/build_config.h"
|
||||
#include "build/assert.h"
|
||||
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
|
@ -108,6 +109,10 @@ static serialPort_t *cliPort;
|
|||
static bufWriter_t *cliWriter;
|
||||
static uint8_t cliWriteBuffer[sizeof(*cliWriter) + 16];
|
||||
|
||||
#if defined(USE_ASSERT)
|
||||
static void cliAssert(char *cmdline);
|
||||
#endif
|
||||
|
||||
static void cliAux(char *cmdline);
|
||||
static void cliRxFail(char *cmdline);
|
||||
static void cliAdjustmentRange(char *cmdline);
|
||||
|
@ -260,6 +265,9 @@ typedef struct {
|
|||
// should be sorted a..z for bsearch()
|
||||
const clicmd_t cmdTable[] = {
|
||||
CLI_COMMAND_DEF("adjrange", "configure adjustment ranges", NULL, cliAdjustmentRange),
|
||||
#if defined(USE_ASSERT)
|
||||
CLI_COMMAND_DEF("assert", "", NULL, cliAssert),
|
||||
#endif
|
||||
CLI_COMMAND_DEF("aux", "configure modes", NULL, cliAux),
|
||||
#ifdef LED_STRIP
|
||||
CLI_COMMAND_DEF("color", "configure colors", NULL, cliColor),
|
||||
|
@ -994,6 +1002,25 @@ static void cliRxFail(char *cmdline)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(USE_ASSERT)
|
||||
static void cliAssert(char *cmdline)
|
||||
{
|
||||
UNUSED(cmdline);
|
||||
|
||||
if (assertFailureLine) {
|
||||
if (assertFailureFile) {
|
||||
cliPrintf("Assertion failed at line %d, file %s\r\n", assertFailureLine, assertFailureFile);
|
||||
}
|
||||
else {
|
||||
cliPrintf("Assertion failed at line %d\r\n", assertFailureLine);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cliPrintf("No assert() failed\r\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void cliAux(char *cmdline)
|
||||
{
|
||||
int i, val = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue