diff --git a/src/main/cli/settings.c b/src/main/cli/settings.c index 6815c75af..4a6a5e42e 100644 --- a/src/main/cli/settings.c +++ b/src/main/cli/settings.c @@ -47,6 +47,7 @@ #include "config/config.h" #include "fc/controlrate_profile.h" #include "fc/core.h" +#include "fc/rc.h" #include "fc/rc_adjustments.h" #include "fc/rc_controls.h" @@ -721,7 +722,7 @@ const clivalue_t valueTable[] = { { "rc_smoothing_debug_axis", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_RC_SMOOTHING_DEBUG }, PG_RX_CONFIG, offsetof(rxConfig_t, rc_smoothing_debug_axis) }, { "rc_smoothing_input_type", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_RC_SMOOTHING_INPUT_TYPE }, PG_RX_CONFIG, offsetof(rxConfig_t, rc_smoothing_input_type) }, { "rc_smoothing_derivative_type",VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_RC_SMOOTHING_DERIVATIVE_TYPE }, PG_RX_CONFIG, offsetof(rxConfig_t, rc_smoothing_derivative_type) }, - { "rc_smoothing_auto_smoothness",VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 50 }, PG_RX_CONFIG, offsetof(rxConfig_t, rc_smoothing_auto_factor) }, + { "rc_smoothing_auto_smoothness",VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { RC_SMOOTHING_AUTO_FACTOR_MIN, RC_SMOOTHING_AUTO_FACTOR_MAX }, PG_RX_CONFIG, offsetof(rxConfig_t, rc_smoothing_auto_factor) }, #endif // USE_RC_SMOOTHING_FILTER { "fpv_mix_degrees", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 90 }, PG_RX_CONFIG, offsetof(rxConfig_t, fpvCamAngleDegrees) }, diff --git a/src/main/fc/rc.h b/src/main/fc/rc.h index 3e7407e3c..ae2f0bc7c 100644 --- a/src/main/fc/rc.h +++ b/src/main/fc/rc.h @@ -32,6 +32,11 @@ typedef enum { extern uint16_t currentRxRefreshRate; +#ifdef USE_RC_SMOOTHING_FILTER +#define RC_SMOOTHING_AUTO_FACTOR_MIN 0 +#define RC_SMOOTHING_AUTO_FACTOR_MAX 50 +#endif + void processRcCommand(void); float getSetpointRate(int axis); float getRcDeflection(int axis); diff --git a/src/main/msp/msp.c b/src/main/msp/msp.c index d183ffce8..4518b438f 100644 --- a/src/main/msp/msp.c +++ b/src/main/msp/msp.c @@ -3051,7 +3051,11 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP, if (sbufBytesRemaining(src) >= 1) { // Added in MSP API 1.42 #if defined(USE_RC_SMOOTHING_FILTER) - configRebootUpdateCheckU8(&rxConfigMutable()->rc_smoothing_auto_factor, sbufReadU8(src)); + // Added extra validation/range constraint for rc_smoothing_auto_factor as a workaround for a bug in + // the 10.6 configurator where it was possible to submit an invalid out-of-range value. We might be + // able to remove the constraint at some point in the future once the affected versions are deprecated + // enough that the risk is low. + configRebootUpdateCheckU8(&rxConfigMutable()->rc_smoothing_auto_factor, constrain(sbufReadU8(src), RC_SMOOTHING_AUTO_FACTOR_MIN, RC_SMOOTHING_AUTO_FACTOR_MAX)); #else sbufReadU8(src); #endif