Commander: Move telemetry logic to separate functions

This commit is contained in:
acfloria
2018-04-11 15:15:28 +02:00
committed by Beat Küng
parent 443a4016af
commit 1124a397f2
2 changed files with 252 additions and 226 deletions
+27 -9
View File
@@ -64,11 +64,7 @@ using uORB::Subscription;
class Commander : public ModuleBase<Commander>, public ModuleParams
{
public:
Commander() :
ModuleParams(nullptr),
_mission_result_sub(ORB_ID(mission_result))
{
}
Commander();
/** @see ModuleBase */
static int task_spawn(int argc, char *argv[]);
@@ -88,10 +84,6 @@ public:
void enable_hil();
private:
// Subscriptions
Subscription<mission_result_s> _mission_result_sub;
bool handle_command(vehicle_status_s *status_local, const vehicle_command_s &cmd,
actuator_armed_s *armed_local, home_position_s *home, const vehicle_global_position_s &global_pos,
const vehicle_local_position_s &local_pos, orb_advert_t *home_pub, orb_advert_t *command_ack_pub, bool *changed);
@@ -122,6 +114,32 @@ private:
void mission_init();
/**
* Update the telemetry status and the corresponding status variables.
* Perform system checks when new telemetry link connected.
*/
void poll_telemetry_status(bool checkAirspeed, bool *hotplug_timeout);
/**
* Checks the status of all available data links and handles switching between different system telemetry states.
*/
void data_link_checks(int32_t highlatencydatalink_loss_timeout, int32_t highlatencydatalink_regain_timeout,
int32_t datalink_loss_timeout, int32_t datalink_regain_timeout, bool *status_changed);
// telemetry variables
int _telemetry_subs[ORB_MULTI_MAX_INSTANCES] = {};
uint64_t _telemetry_last_heartbeat[ORB_MULTI_MAX_INSTANCES] = {};
uint64_t _telemetry_last_dl_loss[ORB_MULTI_MAX_INSTANCES] = {};
bool _telemetry_preflight_checks_reported[ORB_MULTI_MAX_INSTANCES] = {};
bool _telemetry_lost[ORB_MULTI_MAX_INSTANCES] = {};
bool _telemetry_high_latency[ORB_MULTI_MAX_INSTANCES] = {};
// publisher
orb_advert_t _vehicle_cmd_pub = nullptr;
// subscriptions
Subscription<mission_result_s> _mission_result_sub;
};
#endif /* COMMANDER_HPP_ */