Skip to content

Commit e2c7e67

Browse files
committed
fix: force currentMixerMode to MIXER_QUADX under USE_QUAD_MIXER_ONLY
CodeRabbit review on PR#1417 (github.com//pull/1417#issuecomment-5453591327): mixerInit() set currentMixerMode from the persisted mixerConfig() value unconditionally. config.c's validateAndFixConfig() -- which would normally reset a stale mixer mode -- is itself skipped under USE_QUAD_MIXER_ONLY. A device reflashed to a quad-only build with a persisted non-quad mode (e.g. MIXER_TRI) would carry that value into servoConfigureOutput()'s servoMixers[currentMixerMode] lookup whenever a servo feature is active, loading the wrong servo rules for the airframe actually being flown (motors hardcoded to QuadX, servos configured per the stale mode). Reachable on a normal boot, no exotic timing required. Fix: mixerInit() forces currentMixerMode = MIXER_QUADX under the flag, ignoring the persisted value -- single source of truth for every downstream consumer (servos.c, mixerIsTricopter(), etc.). Also (CodeRabbit P3, same review): the `smix` CLI help text still advertised `load <mixer>` under USE_QUAD_MIXER_ONLY, where cliServoMix() always rejects it with "Invalid name". Split into two full CLI_COMMAND_DEF entries (embedding a preprocessor directive inside a single macro call's argument list is non-portable and produced its own new warning -- confirmed via build, reverted that approach). 48/48 unit tests pass. Both configurations (with/without the flag) build clean, zero warnings. Normal-build .elf size unchanged (byte-identical to pre-fix).
1 parent 5870cc7 commit e2c7e67

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/main/flight/mixer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,12 @@ void initEscEndpoints(void) {
428428
}
429429

430430
void mixerInit(mixerMode_e mixerMode) {
431+
#ifdef USE_QUAD_MIXER_ONLY
432+
UNUSED(mixerMode);
433+
currentMixerMode = MIXER_QUADX;
434+
#else
431435
currentMixerMode = mixerMode;
436+
#endif
432437
initEscEndpoints();
433438
if (mixerIsTricopter()) {
434439
mixerTricopterInit();

src/main/interface/cli.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4602,10 +4602,16 @@ const clicmd_t cmdTable[] = {
46024602
CLI_COMMAND_DEF("signature", "get / set the board type signature", "[signature]", cliSignature),
46034603
#endif
46044604
#ifdef USE_SERVOS
4605+
#ifndef USE_QUAD_MIXER_ONLY
46054606
CLI_COMMAND_DEF("smix", "servo mixer", "<rule> <servo> <source> <rate> <speed> <min> <max> <box>\r\n"
46064607
"\treset\r\n"
46074608
"\tload <mixer>\r\n"
46084609
"\treverse <servo> <source> r|n", cliServoMix),
4610+
#else
4611+
CLI_COMMAND_DEF("smix", "servo mixer", "<rule> <servo> <source> <rate> <speed> <min> <max> <box>\r\n"
4612+
"\treset\r\n"
4613+
"\treverse <servo> <source> r|n", cliServoMix),
4614+
#endif
46094615
#endif
46104616
CLI_COMMAND_DEF("status", "show status", NULL, cliStatus),
46114617
#ifndef SKIP_TASK_STATISTICS

0 commit comments

Comments
 (0)