From 64fa20a3e45977a2ab764e64ab8777b7c6782a50 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sun, 15 Mar 2015 13:32:43 -0700 Subject: [PATCH] Validate RC_CHAN_COUNT --- src/AutoPilotPlugins/PX4/FlightModesComponentController.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponentController.cc b/src/AutoPilotPlugins/PX4/FlightModesComponentController.cc index ef5c346f8..d6cace7d1 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponentController.cc +++ b/src/AutoPilotPlugins/PX4/FlightModesComponentController.cc @@ -69,7 +69,11 @@ void FlightModesComponentController::_validateConfiguration(void) { _validConfiguration = true; - _channelCount = _autoPilotPlugin->factExists("RC_CHAN_CNT") ? _autoPilotPlugin->getFact("RC_CHAN_CNT")->value().toInt() : 18; + _channelCount = _autoPilotPlugin->factExists("RC_CHAN_CNT") ? _autoPilotPlugin->getFact("RC_CHAN_CNT")->value().toInt() : _chanMax; + if (_channelCount <= 0 || _channelCount > _chanMax) { + // Parameter exists, but has not yet been set or is invalid. Use default + _channelCount = _chanMax; + } // Make sure switches are valid and within channel range -- 2.22.0