1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 03:50:02 +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; static char __attribute__ ((section(".custom_defaults_end_address"))) *customDefaultsEnd = CUSTOM_DEFAULTS_END;
#endif #endif
#define ERROR_INVALID_NAME "INVALID NAME: %s"
#define ERROR_MESSAGE "%s CANNOT BE CHANGED. CURRENT VALUE: '%s'"
#ifndef USE_QUAD_MIXER_ONLY #ifndef USE_QUAD_MIXER_ONLY
// sync this with mixerMode_e // sync this with mixerMode_e
static const char * const mixerNames[] = { static const char * const mixerNames[] = {
@ -1793,7 +1796,7 @@ static void cliMotorMix(const char *cmdName, char *cmdline)
len = strlen(ptr); len = strlen(ptr);
for (uint32_t i = 0; ; i++) { for (uint32_t i = 0; ; i++) {
if (mixerNames[i] == NULL) { if (mixerNames[i] == NULL) {
cliPrintErrorLinef(cmdName, "INVALID NAME"); cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
break; break;
} }
if (strncasecmp(ptr, mixerNames[i], len) == 0) { if (strncasecmp(ptr, mixerNames[i], len) == 0) {
@ -2274,7 +2277,7 @@ static void cliServoMix(const char *cmdName, char *cmdline)
len = strlen(ptr); len = strlen(ptr);
for (uint32_t i = 0; ; i++) { for (uint32_t i = 0; ; i++) {
if (mixerNames[i] == NULL) { if (mixerNames[i] == NULL) {
cliPrintErrorLinef(cmdName, "INVALID NAME"); cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
break; break;
} }
if (strncasecmp(ptr, mixerNames[i], len) == 0) { 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) #if defined(USE_BOARD_INFO)
#define ERROR_MESSAGE "%s CANNOT BE CHANGED. CURRENT VALUE: '%s'"
static void printBoardName(dumpFlags_t dumpMask) static void printBoardName(dumpFlags_t dumpMask)
{ {
if (!(dumpMask & DO_DIFF) || strlen(getBoardName())) { if (!(dumpMask & DO_DIFF) || strlen(getBoardName())) {
@ -3303,7 +3304,7 @@ static void cliFeature(const char *cmdName, char *cmdline)
for (uint32_t i = 0; ; i++) { for (uint32_t i = 0; ; i++) {
if (featureNames[i] == NULL) { if (featureNames[i] == NULL) {
cliPrintErrorLinef(cmdName, "INVALID NAME"); cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
break; break;
} }
@ -3389,7 +3390,7 @@ static void processBeeperCommand(const char *cmdName, char *cmdline, uint32_t *o
for (uint32_t i = 0; ; i++) { for (uint32_t i = 0; ; i++) {
if (i == beeperCount) { if (i == beeperCount) {
cliPrintErrorLinef(cmdName, "INVALID NAME"); cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
break; break;
} }
if (strncasecmp(cmdline, beeperNameForTableIndex(i), len) == 0 && beeperModeMaskForTableIndex(i) & (allowedFlags | BEEPER_GET_FLAG(BEEPER_ALL))) { 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++) { for (uint32_t i = 0; ; i++) {
if (mixerNames[i] == NULL) { if (mixerNames[i] == NULL) {
cliPrintErrorLinef(cmdName, "INVALID NAME"); cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
return; return;
} }
if (strncasecmp(cmdline, mixerNames[i], len) == 0) { 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; rateProfileIndexToUse = CURRENT_PROFILE_INDEX;
if (!matchedCommands) { 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); const uint16_t index = cliGetSettingIndex(cmdline, variableNameLength);
if (index >= valueTableEntryCount) { if (index >= valueTableEntryCount) {
cliPrintErrorLinef(cmdName, "INVALID NAME"); cliPrintErrorLinef(cmdName, ERROR_INVALID_NAME, cmdline);
return; return;
} }
const clivalue_t *val = &valueTable[index]; const clivalue_t *val = &valueTable[index];