Browse Source

Fixed compile error for MAVLink

QGC4.4
pixhawk 15 years ago
parent
commit
cd9d96b09c
  1. 1
      .gitignore
  2. 13
      src/uas/PxQuadMAV.cc
  3. 2
      src/uas/PxQuadMAV.h
  4. 2
      src/ui/MainWindow.h
  5. 26
      src/ui/watchdog/WatchdogControl.cc
  6. 19
      src/ui/watchdog/WatchdogControl.h

1
.gitignore vendored

@ -16,6 +16,7 @@ tmp @@ -16,6 +16,7 @@ tmp
debug
release
qgroundcontrol
mavlinkgen
*.wav
qgroundcontrol.xcodeproj/**
doc/html

13
src/uas/PxQuadMAV.cc

@ -52,3 +52,16 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) @@ -52,3 +52,16 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message)
break;
}
}
void PxQuadMAV::sendProcessCommand(int watchdogId, int processId, unsigned int command)
{
mavlink_watchdog_command_t payload;
payload.target_system_id = uasId;
payload.watchdog_id = watchdogId;
payload.process_id = processId;
payload.command_id = (uint8_t)command;
mavlink_message_t msg;
mavlink_msg_watchdog_command_encode(sysid, compid, &msg, &payload);
sendMessage(msg);
}

2
src/uas/PxQuadMAV.h

@ -11,6 +11,8 @@ public: @@ -11,6 +11,8 @@ public:
public slots:
/** @brief Receive a MAVLink message from this MAV */
void receiveMessage(LinkInterface* link, mavlink_message_t message);
/** @brief Send a command to an onboard process */
void sendProcessCommand(int watchdogId, int processId, unsigned int command);
signals:
void watchdogReceived(int systemId, int watchdogId, int processCount);
void processReceived(int systemId, int watchdogId, int processId, QString name, QString arguments, int timeout);

2
src/ui/MainWindow.h

@ -53,7 +53,6 @@ This file is part of the PIXHAWK project @@ -53,7 +53,6 @@ This file is part of the PIXHAWK project
#include "ObjectDetectionView.h"
#include "HUD.h"
#include "PFD.h"
#include "GaugePanel.h"
#include "JoystickWidget.h"
#include "input/JoystickInput.h"
#include "DebugConsole.h"
@ -147,7 +146,6 @@ protected: @@ -147,7 +146,6 @@ protected:
XMLCommProtocolWidget* protocol;
HDDisplay* headDown1;
HDDisplay* headDown2;
GaugePanel* gaugePanel;
// Popup widgets
JoystickWidget* joystickWidget;

26
src/ui/watchdog/WatchdogControl.cc

@ -1,10 +1,12 @@ @@ -1,10 +1,12 @@
#include "WatchdogControl.h"
#include "ui_WatchdogControl.h"
#include "PxQuadMAV.h"
#include <QDebug>
WatchdogControl::WatchdogControl(QWidget *parent) :
WatchdogControl::WatchdogControl(UASInterface* uas, QWidget *parent) :
QWidget(parent),
mav(NULL),
ui(new Ui::WatchdogControl)
{
ui->setupUi(this);
@ -15,6 +17,16 @@ WatchdogControl::~WatchdogControl() @@ -15,6 +17,16 @@ WatchdogControl::~WatchdogControl()
delete ui;
}
void WatchdogControl::setUAS(UASInterface* uas)
{
PxQuadMAV* qmav = dynamic_cast<PxQuadMAV>(uas);
if (qmav)
{
connect(qmav, SIGNAL(processReceived(int,int,int,QString,QString,int)), this, SLOT(addProcess(int,int,int,QString,QString,int)));
}
}
void WatchdogControl::updateWatchdog(int systemId, int watchdogId, unsigned int processCount)
{
// request the watchdog with the given ID
@ -101,17 +113,7 @@ WatchdogControl::ProcessInfo& WatchdogControl::WatchdogInfo::getProcess(uint16_t @@ -101,17 +113,7 @@ WatchdogControl::ProcessInfo& WatchdogControl::WatchdogInfo::getProcess(uint16_t
*/
void WatchdogControl::sendCommand(const WatchdogID& w_id, uint16_t p_id, Command::Enum command)
{
/*
mavlink_watchdog_command_t payload;
payload.target_system_id = w_id.system_id_;
payload.watchdog_id = w_id.watchdog_id_;
payload.process_id = p_id;
payload.command_id = (uint8_t)command;
mavlink_message_t msg;
mavlink_msg_watchdog_command_encode(sysid, compid, &msg, &payload);
mavlink_message_t_publish(this->lcm_, "MAVLINK", &msg);*/
//std::cout << "--> sent mavlink_watchdog_command_t " << payload.target_system_id << " / " << payload.watchdog_id << " / " << payload.process_id << " / " << (int)payload.command_id << std::endl;
emit sendProcessCommand(w_id.watchdog_id_, p_id, command);
}
void WatchdogControl::changeEvent(QEvent *e)

19
src/ui/watchdog/WatchdogControl.h

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
#ifndef WATCHDOGCONTROL_H
#define WATCHDOGCONTROL_H
#include <inttypes.h>
#include <QWidget>
#include <QTimer>
@ -8,6 +10,8 @@ @@ -8,6 +10,8 @@
#include <string>
#include <sstream>
#include "UASInterface.h"
namespace Ui {
class WatchdogControl;
}
@ -90,7 +94,7 @@ public: @@ -90,7 +94,7 @@ public:
QTimer* timeoutTimer_; ///< Internal timer, used to measure the time since the last heartbeat message
};
WatchdogControl(QWidget *parent = 0);
WatchdogControl(UASInterface* uas, QWidget *parent = 0);
~WatchdogControl();
static const uint16_t ALL = (uint16_t)-1; ///< A magic value for a process-ID which addresses "all processes"
@ -102,9 +106,14 @@ public slots: @@ -102,9 +106,14 @@ public slots:
void addProcess(int systemId, int watchdogId, int processId, QString name, QString arguments, int timeout);
void updateProcess(int systemId, int watchdogId, int processId, int state, bool muted, int crashed, int pid);
signals:
void sendProcessCommand(int watchdogId, int processId, unsigned int command);
protected:
void changeEvent(QEvent *e);
UASInterface* mav;
private:
Ui::WatchdogControl *ui;
@ -120,9 +129,9 @@ private: @@ -120,9 +129,9 @@ private:
///! Convert a value to std::string
template <class T>
std::string convertToString(T value)
std::string convertToString(T value)
{
std::ostringstream oss;
oss << value;
return oss.str();
std::ostringstream oss;
oss << value;
return oss.str();
}

Loading…
Cancel
Save