diff options
author | t0ni0 <azntonio789@gmail.com> | 2014-06-05 04:03:40 -0400 |
---|---|---|
committer | t0ni0 <azntonio789@gmail.com> | 2014-06-07 12:31:50 -0400 |
commit | 2a79a9a4e4ebae2e85dab64ae98ff2a17e421ea2 (patch) | |
tree | e7c05c9686b3266c92cc2e034071165572e28098 /src/modules/mc_att_control/mc_att_control_main.cpp | |
parent | af56879fdd94c1b712657e071324b3a6f147caa7 (diff) | |
download | px4-firmware-2a79a9a4e4ebae2e85dab64ae98ff2a17e421ea2.tar.gz px4-firmware-2a79a9a4e4ebae2e85dab64ae98ff2a17e421ea2.tar.bz2 px4-firmware-2a79a9a4e4ebae2e85dab64ae98ff2a17e421ea2.zip |
Close fds when not needed
File descriptors get closed when not needed by offboard mode
to allow position and attitude controllers to advertise and publish.
Diffstat (limited to 'src/modules/mc_att_control/mc_att_control_main.cpp')
-rw-r--r-- | src/modules/mc_att_control/mc_att_control_main.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/modules/mc_att_control/mc_att_control_main.cpp b/src/modules/mc_att_control/mc_att_control_main.cpp index 20e016da3..26c0c386f 100644 --- a/src/modules/mc_att_control/mc_att_control_main.cpp +++ b/src/modules/mc_att_control/mc_att_control_main.cpp @@ -584,9 +584,15 @@ MulticopterAttitudeControl::control_attitude(float dt) if (_att_sp_pub > 0) { orb_publish(ORB_ID(vehicle_attitude_setpoint), _att_sp_pub, &_v_att_sp); - } else { + } else if (!_v_control_mode.flag_control_offboard_enabled) { _att_sp_pub = orb_advertise(ORB_ID(vehicle_attitude_setpoint), &_v_att_sp); } + + /* Close fd to let offboard att sp be advertised in mavlink receiver*/ + if (_v_control_mode.flag_control_offboard_enabled && _att_sp_pub > 0) { + close(_att_sp_pub); + _att_sp_pub = -1; + } } /* rotation matrix for current state */ |