Bug fix fmu hard fault on pwm info

A hardfault was happening on:
    fmu stop
    fmu mode_pwm
    pwm info

   The _mixer was null and being dereferenced to access the trim
   setting that were moved to the mixer from the fmu.

   This commit fixes that but making the getter issue a warning
   and the setter fail.
This commit is contained in:
David Sidrane
2018-09-12 13:57:36 -07:00
committed by Lorenz Meier
parent 945a532260
commit b578419e09
+14 -1
View File
@@ -1735,6 +1735,12 @@ PX4FMU::pwm_ioctl(file *filp, int cmd, unsigned long arg)
break;
}
if (_mixers == nullptr) {
PX4_ERR("error: no mixer loaded");
ret = -EIO;
break;
}
/* copy the trim values to the mixer offsets */
_mixers->set_trims((int16_t *)pwm->values, pwm->channel_count);
PX4_DEBUG("set_trims: %d, %d, %d, %d", pwm->values[0], pwm->values[1], pwm->values[2], pwm->values[3]);
@@ -1745,7 +1751,14 @@ PX4FMU::pwm_ioctl(file *filp, int cmd, unsigned long arg)
case PWM_SERVO_GET_TRIM_PWM: {
struct pwm_output_values *pwm = (struct pwm_output_values *)arg;
pwm->channel_count = _mixers->get_trims((int16_t *)pwm->values);
if (_mixers == nullptr) {
memset(pwm, 0, sizeof(pwm_output_values));
PX4_WARN("warning: trim values not valid - no mixer loaded");
} else {
pwm->channel_count = _mixers->get_trims((int16_t *)pwm->values);
}
break;
}