From d67528e06a8eac957bf74cbefb17f659e12c7fa1 Mon Sep 17 00:00:00 2001 From: LM Date: Tue, 9 Aug 2011 19:02:45 +0200 Subject: [PATCH] Updated to latest MAVLink --- src/QGCCore.cc | 1 - src/comm/MAVLinkProtocol.cc | 2 - src/comm/MAVLinkSimulationLink.cc | 8 ++-- src/comm/MAVLinkSimulationWaypointPlanner.cc | 10 ++--- src/comm/QGCMAVLink.h | 1 + src/main.cc | 1 + src/uas/PxQuadMAV.cc | 2 +- src/uas/UAS.cc | 10 ++--- thirdParty/mavlink/include/bittest.c | 39 -------------------- 9 files changed, 17 insertions(+), 57 deletions(-) delete mode 100644 thirdParty/mavlink/include/bittest.c diff --git a/src/QGCCore.cc b/src/QGCCore.cc index ca6bf0c9a..c1f460a0c 100644 --- a/src/QGCCore.cc +++ b/src/QGCCore.cc @@ -44,7 +44,6 @@ This file is part of the QGROUNDCONTROL project #include "configuration.h" #include "QGC.h" #include "QGCCore.h" -#include "MG.h" #include "MainWindow.h" #include "GAudioOutput.h" diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index 098fe65ff..7a2bd1efd 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -17,7 +17,6 @@ #include #include -//#include "MG.h" #include "MAVLinkProtocol.h" #include "UASInterface.h" #include "UASManager.h" @@ -28,7 +27,6 @@ #include "ArduPilotMegaMAV.h" #include "configuration.h" #include "LinkManager.h" -//#include "MainWindow.h" #include "QGCMAVLink.h" #include "QGCMAVLinkUASFactory.h" #include "QGC.h" diff --git a/src/comm/MAVLinkSimulationLink.cc b/src/comm/MAVLinkSimulationLink.cc index 4ffd5ec4b..8fb07e893 100644 --- a/src/comm/MAVLinkSimulationLink.cc +++ b/src/comm/MAVLinkSimulationLink.cc @@ -716,11 +716,11 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size) } break; // EXECUTE OPERATOR ACTIONS - case MAVLINK_MSG_ID_ACTION: { - mavlink_action_t action; - mavlink_msg_action_decode(&msg, &action); + case MAVLINK_MSG_ID_COMMAND: { + mavlink_command_t action; + mavlink_msg_command_decode(&msg, &action); - qDebug() << "SIM" << "received action" << action.action << "for system" << action.target; + qDebug() << "SIM" << "received action" << action.command << "for system" << action.target_system; // FIXME MAVLINKV10PORTINGNEEDED // switch (action.action) { diff --git a/src/comm/MAVLinkSimulationWaypointPlanner.cc b/src/comm/MAVLinkSimulationWaypointPlanner.cc index d78b4d5bf..0f229d2f5 100644 --- a/src/comm/MAVLinkSimulationWaypointPlanner.cc +++ b/src/comm/MAVLinkSimulationWaypointPlanner.cc @@ -815,11 +815,11 @@ void MAVLinkSimulationWaypointPlanner::mavlink_handler (const mavlink_message_t* break; } - case MAVLINK_MSG_ID_ACTION: { // special action from ground station - mavlink_action_t action; - mavlink_msg_action_decode(msg, &action); - if(action.target == systemid) { - if (verbose) qDebug("Waypoint: received message with action %d\n", action.action); + case MAVLINK_MSG_ID_COMMAND: { // special action from ground station + mavlink_command_t action; + mavlink_msg_command_decode(msg, &action); + if(action.target_system == systemid) { + if (verbose) qDebug("Waypoint: received message with action %d\n", action.command); // switch (action.action) { // case MAV_ACTION_LAUNCH: // if (verbose) std::cerr << "Launch received" << std::endl; diff --git a/src/comm/QGCMAVLink.h b/src/comm/QGCMAVLink.h index b03e72e27..3debe72f2 100644 --- a/src/comm/QGCMAVLink.h +++ b/src/comm/QGCMAVLink.h @@ -30,6 +30,7 @@ This file is part of the QGROUNDCONTROL project #ifndef QGCMAVLINK_H #define QGCMAVLINK_H +#define MAVLINK_NO_DATA #include #include diff --git a/src/main.cc b/src/main.cc index 910c57e6b..b4ff08262 100644 --- a/src/main.cc +++ b/src/main.cc @@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project #include "QGCCore.h" #include "MainWindow.h" #include "configuration.h" +#include "mavlink_data.h" /* SDL does ugly things to main() */ diff --git a/src/uas/PxQuadMAV.cc b/src/uas/PxQuadMAV.cc index 1ad0fbfe8..478d5d87d 100644 --- a/src/uas/PxQuadMAV.cc +++ b/src/uas/PxQuadMAV.cc @@ -65,7 +65,7 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) mavlink_msg_pattern_detected_decode(&message, &detected); QByteArray b; b.resize(256); - mavlink_msg_pattern_detected_get_file(&message, (int8_t*)b.data()); + mavlink_msg_pattern_detected_get_file(&message, b.data()); b.append('\0'); QString name = QString(b); if (detected.type == 0) diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index ff463e28a..3efaebda2 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -809,16 +809,16 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) emit parameterChanged(uasId, message.compid, value.param_count, value.param_index, parameterName, val); } break; - case MAVLINK_MSG_ID_ACTION_ACK: - mavlink_action_ack_t ack; - mavlink_msg_action_ack_decode(&message, &ack); + case MAVLINK_MSG_ID_CMD_ACK: + mavlink_cmd_ack_t ack; + mavlink_msg_cmd_ack_decode(&message, &ack); if (ack.result == 1) { - emit textMessageReceived(uasId, message.compid, 0, tr("SUCCESS: Executed action: %1").arg(ack.action)); + emit textMessageReceived(uasId, message.compid, 0, tr("SUCCESS: Executed CMD: %1").arg(ack.cmd)); } else { - emit textMessageReceived(uasId, message.compid, 0, tr("FAILURE: Rejected action: %1").arg(ack.action)); + emit textMessageReceived(uasId, message.compid, 0, tr("FAILURE: Rejected CMD: %1").arg(ack.cmd)); } break; case MAVLINK_MSG_ID_DEBUG: diff --git a/thirdParty/mavlink/include/bittest.c b/thirdParty/mavlink/include/bittest.c deleted file mode 100644 index c966b72af..000000000 --- a/thirdParty/mavlink/include/bittest.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -int main(int argc, char* argv[]) -{ - - uint8_t bitfield = 254; // 11111110 - - uint8_t mask = 128; // 10000000 - - uint8_t result = (bitfield & mask); - - printf("0x%02x\n", bitfield); - - // Transform into network order - - generic_32bit bin; - bin.i = 1; - printf("First byte in (little endian) 0x%02x\n", bin.b[0]); - generic_32bit bout; - bout.b[0] = bin.b[3]; - bout.b[1] = bin.b[2]; - bout.b[2] = bin.b[1]; - bout.b[3] = bin.b[0]; - printf("Last byte out (big endian) 0x%02x\n", bout.b[3]); - - uint8_t n = 5; - printf("Mask is 0x%02x\n", ((uint32_t)(1 << n)) - 1); // = 2^n - 1 - - int32_t encoded = 2; - uint8_t bits = 2; - - uint8_t packet[MAVLINK_MAX_PACKET_LEN]; - uint8_t packet_index = 0; - uint8_t bit_index = 0; - - put_bitfield_n_by_index(encoded, bits, packet_index, bit_index, &bit_index, packet); - -} -- 2.22.0