Skip to content

Commit

Permalink
Merge pull request mavlink#4136 from DonLakeFlyer/Mav2ChannelStatus
Browse files Browse the repository at this point in the history
Use single mavlink_status_t array
  • Loading branch information
DonLakeFlyer authored Oct 15, 2016
2 parents 558bc82 + 16d16ac commit d3f6a08
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/QGCApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ const char* QGCApplication::_lastKnownHomePositionAltKey = "LastKnownHomePosi
const char* QGCApplication::_darkStyleFile = ":/res/styles/style-dark.css";
const char* QGCApplication::_lightStyleFile = ":/res/styles/style-light.css";

// Mavlink status structures for entire app
mavlink_status_t m_mavlink_status[MAVLINK_COMM_NUM_BUFFERS];

// Qml Singleton factories

static QObject* screenToolsControllerSingletonFactory(QQmlEngine*, QJSEngine*)
Expand Down
6 changes: 6 additions & 0 deletions src/Vehicle/Vehicle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,12 @@ void Vehicle::_sendMessageOnLink(LinkInterface* link, mavlink_message_t message)
return;
}

#if 0
// Leaving in for ease in Mav 2.0 testing
mavlink_status_t* mavlinkStatus = mavlink_get_channel_status(link->mavlinkChannel());
qDebug() << "_sendMessageOnLink" << mavlinkStatus << link->mavlinkChannel() << mavlinkStatus->flags << message.magic;
#endif

// Give the plugin a chance to adjust
_firmwarePlugin->adjustOutgoingMavlinkMessage(this, link, &message);

Expand Down
4 changes: 3 additions & 1 deletion src/comm/LinkManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ void LinkManager::_addLink(LinkInterface* link)
mavlink_reset_channel_status(i);
link->_setMavlinkChannel(i);
// Start the channel on Mav 1 protocol
mavlink_get_channel_status(i)->flags = mavlink_get_channel_status(i)->flags | MAVLINK_STATUS_FLAG_OUT_MAVLINK1;
mavlink_status_t* mavlinkStatus = mavlink_get_channel_status(i);
mavlinkStatus->flags = mavlink_get_channel_status(i)->flags | MAVLINK_STATUS_FLAG_OUT_MAVLINK1;
qDebug() << "LinkManager mavlinkStatus" << mavlinkStatus << i << mavlinkStatus->flags;
_mavlinkChannelsUsedBitMask |= 1 << i;
channelSet = true;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/comm/MAVLinkProtocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)

mavlink_status_t* mavlinkStatus = mavlink_get_channel_status(mavlinkChannel);
if (!(mavlinkStatus->flags & MAVLINK_STATUS_FLAG_IN_MAVLINK1) && (mavlinkStatus->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1)) {
qDebug() << "switch to mavlink 2.0" << mavlinkStatus->flags;
qDebug() << "switch to mavlink 2.0" << mavlinkStatus << mavlinkChannel << mavlinkStatus->flags;
mavlinkStatus->flags &= ~MAVLINK_STATUS_FLAG_OUT_MAVLINK1;
} else if ((mavlinkStatus->flags & MAVLINK_STATUS_FLAG_IN_MAVLINK1) && !(mavlinkStatus->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1)) {
qDebug() << "switch to mavlink 1.0" << mavlinkStatus->flags;
qDebug() << "switch to mavlink 1.0" << mavlinkStatus << mavlinkChannel << mavlinkStatus->flags;
mavlinkStatus->flags |= MAVLINK_STATUS_FLAG_OUT_MAVLINK1;
}

Expand Down
5 changes: 5 additions & 0 deletions src/comm/QGCMAVLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
#ifndef QGCMAVLINK_H
#define QGCMAVLINK_H

#define MAVLINK_USE_MESSAGE_INFO
#define MAVLINK_EXTERNAL_RX_STATUS // Single m_mavlink_status instance is in QGCApplication.cc
#include <stddef.h> // Hack workaround for Mav 2.0 header problem with respect to offsetof usage
#include <mavlink_types.h>
extern mavlink_status_t m_mavlink_status[MAVLINK_COMM_NUM_BUFFERS];
#include <mavlink.h>

class QGCMAVLink {
Expand Down
2 changes: 0 additions & 2 deletions src/ui/MAVLinkDecoder.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define MAVLINK_USE_MESSAGE_INFO
#include <stddef.h> // Hack workaround for Mav 2.0 header problem with respect to offsetof usage
#include "QGCMAVLink.h"
#include "MAVLinkDecoder.h"

Expand Down
2 changes: 0 additions & 2 deletions src/ui/QGCMAVLinkInspector.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define MAVLINK_USE_MESSAGE_INFO
#include <stddef.h> // Hack workaround for Mav 2.0 header problem with respect to offsetof usage
#include "QGCMAVLink.h"
#include "QGCMAVLinkInspector.h"
#include "MultiVehicleManager.h"
Expand Down

0 comments on commit d3f6a08

Please sign in to comment.