mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Put the 'CORRUPTED CONFIG' message on a line of its own as well.
This commit is contained in:
parent
bad72c884a
commit
31e8b0425c
1 changed files with 24 additions and 17 deletions
|
@ -390,19 +390,23 @@ static void cliPrintLinef(const char *format, ...)
|
||||||
cliPrintLinefeed();
|
cliPrintLinefeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cliPrintErrorLinef(const char *format, ...)
|
static void cliPrintError(const char *format, ...)
|
||||||
{
|
{
|
||||||
cliPrint("###ERROR: ");
|
cliPrint("###ERROR: ");
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, format);
|
va_start(va, format);
|
||||||
cliPrintfva(format, va);
|
cliPrintfva(format, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
cliPrintLine("###");
|
cliPrint("###");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cliPrintCorruptMessage(int value)
|
static void cliPrintErrorLinef(const char *format, ...)
|
||||||
{
|
{
|
||||||
cliPrintf("%d ###ERROR: CORRUPTED CONFIG###", value);
|
va_list va;
|
||||||
|
va_start(va, format);
|
||||||
|
cliPrintError(format, va);
|
||||||
|
va_end(va);
|
||||||
|
cliPrintLinefeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getMinMax(const clivalue_t *var, int *min, int *max)
|
static void getMinMax(const clivalue_t *var, int *min, int *max)
|
||||||
|
@ -479,37 +483,34 @@ static void printValuePointer(const clivalue_t *var, const void *valuePointer, b
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool valueIsCorrupted = false;
|
||||||
switch (var->type & VALUE_MODE_MASK) {
|
switch (var->type & VALUE_MODE_MASK) {
|
||||||
case MODE_DIRECT:
|
case MODE_DIRECT:
|
||||||
if ((var->type & VALUE_TYPE_MASK) == VAR_UINT32) {
|
if ((var->type & VALUE_TYPE_MASK) == VAR_UINT32) {
|
||||||
if ((uint32_t) value > var->config.u32Max) {
|
|
||||||
cliPrintCorruptMessage(value);
|
|
||||||
} else {
|
|
||||||
cliPrintf("%d", value);
|
cliPrintf("%d", value);
|
||||||
if (full) {
|
if ((uint32_t) value > var->config.u32Max) {
|
||||||
|
valueIsCorrupted = true;
|
||||||
|
} else if (full) {
|
||||||
cliPrintf(" 0 %d", var->config.u32Max);
|
cliPrintf(" 0 %d", var->config.u32Max);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
int min;
|
int min;
|
||||||
int max;
|
int max;
|
||||||
getMinMax(var, &min, &max);
|
getMinMax(var, &min, &max);
|
||||||
|
|
||||||
if ((value < min) || (value > max)) {
|
|
||||||
cliPrintCorruptMessage(value);
|
|
||||||
} else {
|
|
||||||
cliPrintf("%d", value);
|
cliPrintf("%d", value);
|
||||||
if (full) {
|
if ((value < min) || (value > max)) {
|
||||||
|
valueIsCorrupted = true;
|
||||||
|
} else if (full) {
|
||||||
cliPrintf(" %d %d", min, max);
|
cliPrintf(" %d %d", min, max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MODE_LOOKUP:
|
case MODE_LOOKUP:
|
||||||
if (value < lookupTables[var->config.lookup.tableIndex].valueCount) {
|
if (value < lookupTables[var->config.lookup.tableIndex].valueCount) {
|
||||||
cliPrint(lookupTables[var->config.lookup.tableIndex].values[value]);
|
cliPrint(lookupTables[var->config.lookup.tableIndex].values[value]);
|
||||||
} else {
|
} else {
|
||||||
cliPrintCorruptMessage(value);
|
valueIsCorrupted = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MODE_BITSET:
|
case MODE_BITSET:
|
||||||
|
@ -519,6 +520,11 @@ static void printValuePointer(const clivalue_t *var, const void *valuePointer, b
|
||||||
cliPrintf("OFF");
|
cliPrintf("OFF");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (valueIsCorrupted) {
|
||||||
|
cliPrintLinefeed();
|
||||||
|
cliPrintError("CORRUPTED CONFIG: %s = %d", var->name, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3830,6 +3836,7 @@ STATIC_UNIT_TESTED void cliGet(char *cmdline)
|
||||||
}
|
}
|
||||||
cliPrintVarRange(val);
|
cliPrintVarRange(val);
|
||||||
cliPrintVarDefault(val);
|
cliPrintVarDefault(val);
|
||||||
|
|
||||||
matchedCommands++;
|
matchedCommands++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue