FMU: Tighter compile checks and correct use of unsubscribe

This commit is contained in:
Lorenz Meier 2016-12-18 13:54:58 +01:00 committed by Lorenz Meier
parent 4b99a8f28c
commit 97ce9edcac
3 changed files with 8 additions and 18 deletions

View File

@ -35,9 +35,9 @@ px4_add_module(
MAIN fmu
STACK_MAIN 1200
COMPILE_FLAGS
-Weffc++
SRCS
fmu.cpp
px4fmu_params.c
DEPENDS
platforms__common
)

View File

@ -316,6 +316,7 @@ PX4FMU::PX4FMU() :
_pwm_alt_rate_channels(0),
_current_update_rate(0),
_work{},
_vehicle_cmd_sub(-1),
_armed_sub(-1),
_param_sub(-1),
_adc_sub(-1),
@ -730,13 +731,13 @@ PX4FMU::subscribe()
for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) {
if (sub_groups & (1 << i)) {
PX4_DEBUG("subscribe to actuator_controls_%d", i);
DEVICE_DEBUG("subscribe to actuator_controls_%d", i);
_control_subs[i] = orb_subscribe(_control_topics[i]);
}
if (unsub_groups & (1 << i)) {
PX4_DEBUG("unsubscribe from actuator_controls_%d", i);
::close(_control_subs[i]);
DEVICE_DEBUG("unsubscribe from actuator_controls_%d", i);
orb_unsubscribe(_control_subs[i]);
_control_subs[i] = -1;
}
@ -1616,13 +1617,13 @@ void PX4FMU::work_stop()
for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) {
if (_control_subs[i] > 0) {
::close(_control_subs[i]);
orb_unsubscribe(_control_subs[i]);
_control_subs[i] = -1;
}
}
::close(_armed_sub);
::close(_param_sub);
orb_unsubscribe(_armed_sub);
orb_unsubscribe(_param_sub);
/* make sure servos are off */
up_pwm_servo_deinit();

View File

@ -31,17 +31,6 @@
*
****************************************************************************/
/**
* @file px4fmu_params.c
*
* Parameters defined by the PX4FMU driver
*
* @author Lorenz Meier <lorenz@px4.io>
*/
#include <nuttx/config.h>
#include <systemlib/param/param.h>
/**
* Invert direction of aux output channel 1
*