1
0
Fork 0
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:
Konstantin Sharlaimov 2016-08-19 07:48:02 +03:00 committed by GitHub
parent 5b8b9781da
commit e1d8b5eee9
8 changed files with 137 additions and 1 deletions

View file

@ -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;