From 607bb64855a4d0c52e91003b5675cfafab9514ef Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Sat, 9 Mar 2019 15:27:16 -0500 Subject: [PATCH] Fix CLI beacon dump output Previously the `beacon` portion of a `dump` would display the flags associated with `beeper` rather then only the limited set for `beacon`. This would result in output that would cause errors if copy/pasted back in as commands. --- src/main/cli/cli.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/cli/cli.c b/src/main/cli/cli.c index 98480f4141..0ae36f0123 100644 --- a/src/main/cli/cli.c +++ b/src/main/cli/cli.c @@ -165,7 +165,6 @@ extern uint8_t __config_end; #include "cli.h" - static serialPort_t *cliPort; #ifdef STM32F1 @@ -2969,15 +2968,17 @@ static void cliFeature(char *cmdline) } #if defined(USE_BEEPER) -static void printBeeper(uint8_t dumpMask, const uint32_t offFlags, const uint32_t offFlagsDefault, const char *name) +static void printBeeper(uint8_t dumpMask, const uint32_t offFlags, const uint32_t offFlagsDefault, const char *name, const uint32_t allowedFlags) { const uint8_t beeperCount = beeperTableEntryCount(); for (int32_t i = 0; i < beeperCount - 1; i++) { - const char *formatOff = "%s -%s"; - const char *formatOn = "%s %s"; - const uint32_t beeperModeMask = beeperModeMaskForTableIndex(i); - cliDefaultPrintLinef(dumpMask, ~(offFlags ^ offFlagsDefault) & beeperModeMask, offFlags & beeperModeMask ? formatOn : formatOff, name, beeperNameForTableIndex(i)); - cliDumpPrintLinef(dumpMask, ~(offFlags ^ offFlagsDefault) & beeperModeMask, offFlags & beeperModeMask ? formatOff : formatOn, name, beeperNameForTableIndex(i)); + if (beeperModeMaskForTableIndex(i) & allowedFlags) { + const char *formatOff = "%s -%s"; + const char *formatOn = "%s %s"; + const uint32_t beeperModeMask = beeperModeMaskForTableIndex(i); + cliDefaultPrintLinef(dumpMask, ~(offFlags ^ offFlagsDefault) & beeperModeMask, offFlags & beeperModeMask ? formatOn : formatOff, name, beeperNameForTableIndex(i)); + cliDumpPrintLinef(dumpMask, ~(offFlags ^ offFlagsDefault) & beeperModeMask, offFlags & beeperModeMask ? formatOff : formatOn, name, beeperNameForTableIndex(i)); + } } } @@ -5353,11 +5354,11 @@ static void printConfig(char *cmdline, bool doDiff) #if defined(USE_BEEPER) cliPrintHashLine("beeper"); - printBeeper(dumpMask, beeperConfig_Copy.beeper_off_flags, beeperConfig()->beeper_off_flags, "beeper"); + printBeeper(dumpMask, beeperConfig_Copy.beeper_off_flags, beeperConfig()->beeper_off_flags, "beeper", BEEPER_ALLOWED_MODES); #if defined(USE_DSHOT) cliPrintHashLine("beacon"); - printBeeper(dumpMask, beeperConfig_Copy.dshotBeaconOffFlags, beeperConfig()->dshotBeaconOffFlags, "beacon"); + printBeeper(dumpMask, beeperConfig_Copy.dshotBeaconOffFlags, beeperConfig()->dshotBeaconOffFlags, "beacon", DSHOT_BEACON_ALLOWED_MODES); #endif #endif // USE_BEEPER