1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 19:40:31 +03:00

Extend error output (#12063)

This commit is contained in:
haslinghuis 2022-12-20 06:04:06 +01:00 committed by GitHub
parent ccb5998f52
commit 24a83b3c14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -236,6 +236,9 @@ static char __attribute__ ((section(".custom_defaults_start_address"))) *customD
static char __attribute__ ((section(".custom_defaults_end_address"))) *customDefaultsEnd = CUSTOM_DEFAULTS_END;
#endif
#define ERROR_INVALID_NAME "INVALID NAME: %s"
#define ERROR_MESSAGE "%s CANNOT BE CHANGED. CURRENT VALUE: '%s'"
#ifndef USE_QUAD_MIXER_ONLY
// sync this with mixerMode_e
static const char * const mixerNames[] = {
@ -1793,7 +1796,7 @@ static void cliMotorMix(const char *cmdName, char *cmdline)
len = strlen(ptr);
for (uint32_t i = 0; ; i++) {
if (mixerNames[i] == NULL) {
cliPrintErrorLinef(cmdName, "INVALID NAME");
cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
break;
}
if (strncasecmp(ptr, mixerNames[i], len) == 0) {
@ -2274,7 +2277,7 @@ static void cliServoMix(const char *cmdName, char *cmdline)
len = strlen(ptr);
for (uint32_t i = 0; ; i++) {
if (mixerNames[i] == NULL) {
cliPrintErrorLinef(cmdName, "INVALID NAME");
cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
break;
}
if (strncasecmp(ptr, mixerNames[i], len) == 0) {
@ -3120,8 +3123,6 @@ static void printCraftName(dumpFlags_t dumpMask, const pilotConfig_t *pilotConfi
#if defined(USE_BOARD_INFO)
#define ERROR_MESSAGE "%s CANNOT BE CHANGED. CURRENT VALUE: '%s'"
static void printBoardName(dumpFlags_t dumpMask)
{
if (!(dumpMask & DO_DIFF) || strlen(getBoardName())) {
@ -3303,7 +3304,7 @@ static void cliFeature(const char *cmdName, char *cmdline)
for (uint32_t i = 0; ; i++) {
if (featureNames[i] == NULL) {
cliPrintErrorLinef(cmdName, "INVALID NAME");
cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
break;
}
@ -3389,7 +3390,7 @@ static void processBeeperCommand(const char *cmdName, char *cmdline, uint32_t *o
for (uint32_t i = 0; ; i++) {
if (i == beeperCount) {
cliPrintErrorLinef(cmdName, "INVALID NAME");
cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
break;
}
if (strncasecmp(cmdline, beeperNameForTableIndex(i), len) == 0 && beeperModeMaskForTableIndex(i) & (allowedFlags | BEEPER_GET_FLAG(BEEPER_ALL))) {
@ -3989,7 +3990,7 @@ static void cliMixer(const char *cmdName, char *cmdline)
for (uint32_t i = 0; ; i++) {
if (mixerNames[i] == NULL) {
cliPrintErrorLinef(cmdName, "INVALID NAME");
cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
return;
}
if (strncasecmp(cmdline, mixerNames[i], len) == 0) {
@ -4471,7 +4472,7 @@ STATIC_UNIT_TESTED void cliGet(const char *cmdName, char *cmdline)
rateProfileIndexToUse = CURRENT_PROFILE_INDEX;
if (!matchedCommands) {
cliPrintErrorLinef(cmdName, "INVALID NAME");
cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
}
}
@ -4522,7 +4523,7 @@ STATIC_UNIT_TESTED void cliSet(const char *cmdName, char *cmdline)
const uint16_t index = cliGetSettingIndex(cmdline, variableNameLength);
if (index >= valueTableEntryCount) {
cliPrintErrorLinef(cmdName, "INVALID NAME");
cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
return;
}
const clivalue_t *val = &valueTable[index];