Commit cd9d96b0 authored by pixhawk's avatar pixhawk

Fixed compile error for MAVLink

parent fc38a557
...@@ -16,6 +16,7 @@ tmp ...@@ -16,6 +16,7 @@ tmp
debug debug
release release
qgroundcontrol qgroundcontrol
mavlinkgen
*.wav *.wav
qgroundcontrol.xcodeproj/** qgroundcontrol.xcodeproj/**
doc/html doc/html
......
...@@ -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; 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);
}
...@@ -11,6 +11,8 @@ public: ...@@ -11,6 +11,8 @@ public:
public slots: public slots:
/** @brief Receive a MAVLink message from this MAV */ /** @brief Receive a MAVLink message from this MAV */
void receiveMessage(LinkInterface* link, mavlink_message_t message); 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: signals:
void watchdogReceived(int systemId, int watchdogId, int processCount); void watchdogReceived(int systemId, int watchdogId, int processCount);
void processReceived(int systemId, int watchdogId, int processId, QString name, QString arguments, int timeout); void processReceived(int systemId, int watchdogId, int processId, QString name, QString arguments, int timeout);
......
...@@ -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 "ObjectDetectionView.h"
#include "HUD.h" #include "HUD.h"
#include "PFD.h" #include "PFD.h"
#include "GaugePanel.h"
#include "JoystickWidget.h" #include "JoystickWidget.h"
#include "input/JoystickInput.h" #include "input/JoystickInput.h"
#include "DebugConsole.h" #include "DebugConsole.h"
...@@ -147,7 +146,6 @@ protected: ...@@ -147,7 +146,6 @@ protected:
XMLCommProtocolWidget* protocol; XMLCommProtocolWidget* protocol;
HDDisplay* headDown1; HDDisplay* headDown1;
HDDisplay* headDown2; HDDisplay* headDown2;
GaugePanel* gaugePanel;
// Popup widgets // Popup widgets
JoystickWidget* joystickWidget; JoystickWidget* joystickWidget;
......
#include "WatchdogControl.h" #include "WatchdogControl.h"
#include "ui_WatchdogControl.h" #include "ui_WatchdogControl.h"
#include "PxQuadMAV.h"
#include <QDebug> #include <QDebug>
WatchdogControl::WatchdogControl(QWidget *parent) : WatchdogControl::WatchdogControl(UASInterface* uas, QWidget *parent) :
QWidget(parent), QWidget(parent),
mav(NULL),
ui(new Ui::WatchdogControl) ui(new Ui::WatchdogControl)
{ {
ui->setupUi(this); ui->setupUi(this);
...@@ -15,6 +17,16 @@ WatchdogControl::~WatchdogControl() ...@@ -15,6 +17,16 @@ WatchdogControl::~WatchdogControl()
delete ui; 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) void WatchdogControl::updateWatchdog(int systemId, int watchdogId, unsigned int processCount)
{ {
// request the watchdog with the given ID // 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) void WatchdogControl::sendCommand(const WatchdogID& w_id, uint16_t p_id, Command::Enum command)
{ {
/* emit sendProcessCommand(w_id.watchdog_id_, p_id, 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;
} }
void WatchdogControl::changeEvent(QEvent *e) void WatchdogControl::changeEvent(QEvent *e)
......
#ifndef WATCHDOGCONTROL_H #ifndef WATCHDOGCONTROL_H
#define WATCHDOGCONTROL_H #define WATCHDOGCONTROL_H
#include <inttypes.h>
#include <QWidget> #include <QWidget>
#include <QTimer> #include <QTimer>
...@@ -8,6 +10,8 @@ ...@@ -8,6 +10,8 @@
#include <string> #include <string>
#include <sstream> #include <sstream>
#include "UASInterface.h"
namespace Ui { namespace Ui {
class WatchdogControl; class WatchdogControl;
} }
...@@ -30,7 +34,7 @@ public: ...@@ -30,7 +34,7 @@ public:
RequestInfo = 254, RequestInfo = 254,
RequestStatus = 255 RequestStatus = 255
}; };
}; };
///! This struct represents a process on the watchdog. Used to store all values. ///! This struct represents a process on the watchdog. Used to store all values.
...@@ -46,7 +50,7 @@ public: ...@@ -46,7 +50,7 @@ public:
Stopped = 2, Stopped = 2,
Stopped_OK = 3, Stopped_OK = 3,
Stopped_ERROR = 4 Stopped_ERROR = 4
}; };
}; };
///! Constructor - initialize the values ///! Constructor - initialize the values
...@@ -62,8 +66,8 @@ public: ...@@ -62,8 +66,8 @@ public:
uint16_t crashes_; ///< The number of crashes uint16_t crashes_; ///< The number of crashes
int32_t pid_; ///< The PID of the process int32_t pid_; ///< The PID of the process
// Timer requestTimer_; ///< Internal timer, used to repeat status and info requests after some time (in case of packet loss) // Timer requestTimer_; ///< Internal timer, used to repeat status and info requests after some time (in case of packet loss)
// Timer updateTimer_; ///< Internal timer, used to measure the time since the last update (used only for graphics) // Timer updateTimer_; ///< Internal timer, used to measure the time since the last update (used only for graphics)
}; };
///! This struct identifies a watchdog. It's a combination of system-ID and watchdog-ID. implements operator< to be used as key in a std::map ///! This struct identifies a watchdog. It's a combination of system-ID and watchdog-ID. implements operator< to be used as key in a std::map
...@@ -77,7 +81,7 @@ public: ...@@ -77,7 +81,7 @@ public:
///! Comparison operator which is used by std::map ///! Comparison operator which is used by std::map
inline bool operator<(const WatchdogID& other) const inline bool operator<(const WatchdogID& other) const
{ return (this->system_id_ != other.system_id_) ? (this->system_id_ < other.system_id_) : (this->watchdog_id_ < other.watchdog_id_); } { return (this->system_id_ != other.system_id_) ? (this->system_id_ < other.system_id_) : (this->watchdog_id_ < other.watchdog_id_); }
}; };
...@@ -90,7 +94,7 @@ public: ...@@ -90,7 +94,7 @@ public:
QTimer* timeoutTimer_; ///< Internal timer, used to measure the time since the last heartbeat message 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(); ~WatchdogControl();
static const uint16_t ALL = (uint16_t)-1; ///< A magic value for a process-ID which addresses "all processes" 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 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); 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: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
UASInterface* mav;
private: private:
Ui::WatchdogControl *ui; Ui::WatchdogControl *ui;
...@@ -120,9 +129,9 @@ private: ...@@ -120,9 +129,9 @@ private:
///! Convert a value to std::string ///! Convert a value to std::string
template <class T> template <class T>
std::string convertToString(T value) std::string convertToString(T value)
{ {
std::ostringstream oss; std::ostringstream oss;
oss << value; oss << value;
return oss.str(); return oss.str();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment