send autopilot version message on startup and on request

This commit is contained in:
Roman Bapst
2015-05-15 11:18:35 +02:00
committed by Lorenz Meier
parent 4dd343e2de
commit 0eeaa83b3d
3 changed files with 18 additions and 1 deletions
+14
View File
@@ -912,6 +912,18 @@ Mavlink::send_statustext(unsigned char severity, const char *string)
mavlink_logbuffer_write(&_logbuffer, &logmsg);
}
void Mavlink::send_autopilot_capabilites() {
struct vehicle_status_s status;
MavlinkOrbSubscription *status_sub = this->add_orb_subscription(ORB_ID(vehicle_status));
if (status_sub->update(&status)) {
mavlink_autopilot_version_t msg;
msg.capabilities = status.autopilot_capabilites;
this->send_message(MAVLINK_MSG_ID_AUTOPILOT_VERSION, &msg);
}
}
MavlinkOrbSubscription *Mavlink::add_orb_subscription(const orb_id_t topic, int instance)
{
/* check if already subscribed to this topic */
@@ -1434,6 +1446,8 @@ Mavlink::task_main(int argc, char *argv[])
/* now the instance is fully initialized and we can bump the instance count */
LL_APPEND(_mavlink_instances, this);
send_autopilot_capabilites();
while (!_task_should_exit) {
/* main loop */
usleep(_main_loop_delay);
+1
View File
@@ -229,6 +229,7 @@ public:
* @param severity the log level
*/
void send_statustext(unsigned char severity, const char *string);
void send_autopilot_capabilites();
MavlinkStream * get_streams() const { return _streams; }
+3 -1
View File
@@ -278,7 +278,9 @@ MavlinkReceiver::handle_message_command_long(mavlink_message_t *msg)
/* terminate other threads and this thread */
_mavlink->_task_should_exit = true;
} else if (cmd_mavlink.command == MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES) {
/* send autopilot version message */
_mavlink->send_autopilot_capabilites();
} else {
if (msg->sysid == mavlink_system.sysid && msg->compid == mavlink_system.compid) {