mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
LP-245 centralize oplink connection handling in new UAVTalk OPLinkManager
removes duplication of logic in uploader and config plugins connect logic remains the same: once a device is connected, oplink connection is notifued upon having a valid OPLinkStatus.BoradType disconnection logic is changes: used to be based on timeout on OPLinkStatus update loss no oplink disconnection is notified as soon as a device is disconnected TODO : are there cases where the timeout is still needed ?
This commit is contained in:
parent
25020f230a
commit
1e7aa58e95
@ -2,7 +2,8 @@
|
||||
******************************************************************************
|
||||
*
|
||||
* @file connectionmanager.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
|
@ -2,7 +2,8 @@
|
||||
******************************************************************************
|
||||
*
|
||||
* @file monitorgadgetfactory.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup telemetryplugin
|
||||
@ -57,11 +58,11 @@ MonitorWidget *MonitorGadgetFactory::createMonitorWidget(QWidget *parent)
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
TelemetryManager *tm = pm->getObject<TelemetryManager>();
|
||||
|
||||
connect(tm, SIGNAL(connected()), widget, SLOT(telemetryConnected()));
|
||||
connect(tm, SIGNAL(disconnected()), widget, SLOT(telemetryDisconnected()));
|
||||
// connect(tm, SIGNAL(connected()), widget, SLOT(telemetryConnected()));
|
||||
// connect(tm, SIGNAL(disconnected()), widget, SLOT(telemetryDisconnected()));
|
||||
connect(tm, SIGNAL(telemetryUpdated(double, double)), widget, SLOT(telemetryUpdated(double, double)));
|
||||
|
||||
// and connect widget to connection manager (for retro compatibility)
|
||||
// connect widget to connection manager
|
||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||
|
||||
connect(cm, SIGNAL(deviceConnected(QIODevice *)), widget, SLOT(telemetryConnected()));
|
||||
|
@ -1,3 +1,30 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file monitorwidget.cpp
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup telemetryplugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "monitorwidget.h"
|
||||
|
||||
#include <utils/stylehelper.h>
|
||||
@ -200,7 +227,7 @@ MonitorWidget::~MonitorWidget()
|
||||
|
||||
void MonitorWidget::telemetryConnected()
|
||||
{
|
||||
qDebug() << "telemetry connected";
|
||||
qDebug() << "MonitorWidget::telemetryConnected";
|
||||
if (!connected) {
|
||||
// flash the lights
|
||||
setToolTip(tr("Connected"));
|
||||
@ -211,7 +238,7 @@ void MonitorWidget::telemetryConnected()
|
||||
|
||||
void MonitorWidget::telemetryDisconnected()
|
||||
{
|
||||
qDebug() << "telemetry disconnected";
|
||||
qDebug() << "MonitorWidget::telemetryDisconnected";
|
||||
if (connected) {
|
||||
connected = false;
|
||||
|
||||
|
@ -1,3 +1,30 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file monitorwidget.h
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup telemetryplugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef MONITORWIDGET_H
|
||||
#define MONITORWIDGET_H
|
||||
|
||||
|
126
ground/gcs/src/plugins/uavtalk/oplinkmanager.cpp
Normal file
126
ground/gcs/src/plugins/uavtalk/oplinkmanager.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file oplinkmanager.cpp
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup UAVTalkPlugin UAVTalk Plugin
|
||||
* @{
|
||||
* @brief The UAVTalk protocol plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "oplinkmanager.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/connectionmanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <uavobjects/uavobjectmanager.h>
|
||||
|
||||
#include <oplinkstatus.h>
|
||||
|
||||
OPLinkManager::OPLinkManager() : QObject(), m_isConnected(false), m_opLinkType(OPLinkManager::OPLINK_UNKNOWN)
|
||||
{
|
||||
// conenct to the connection manager
|
||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||
|
||||
connect(cm, SIGNAL(deviceConnected(QIODevice *)), this, SLOT(onDeviceConnect()));
|
||||
connect(cm, SIGNAL(deviceDisconnected()), this, SLOT(onDeviceDisconnect()));
|
||||
|
||||
if (cm->isConnected()) {
|
||||
onDeviceConnect();
|
||||
}
|
||||
}
|
||||
|
||||
OPLinkManager::~OPLinkManager()
|
||||
{}
|
||||
|
||||
bool OPLinkManager::isConnected() const
|
||||
{
|
||||
return m_isConnected;
|
||||
}
|
||||
|
||||
void OPLinkManager::onDeviceConnect()
|
||||
{
|
||||
if (m_isConnected) {
|
||||
return;
|
||||
}
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pm);
|
||||
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objManager);
|
||||
|
||||
m_opLinkStatus = OPLinkStatus::GetInstance(objManager);
|
||||
Q_ASSERT(m_opLinkStatus);
|
||||
|
||||
onOPLinkStatusUpdate();
|
||||
}
|
||||
|
||||
void OPLinkManager::onDeviceDisconnect()
|
||||
{
|
||||
onOPLinkDisconnect();
|
||||
}
|
||||
|
||||
void OPLinkManager::onOPLinkStatusUpdate()
|
||||
{
|
||||
quint8 type = m_opLinkStatus->getBoardType();
|
||||
|
||||
switch (type) {
|
||||
case 0x03:
|
||||
m_opLinkType = OPLINK_MINI;
|
||||
onOPLinkConnect();
|
||||
break;
|
||||
case 0x09:
|
||||
m_opLinkType = OPLINK_REVOLUTION;
|
||||
onOPLinkConnect();
|
||||
break;
|
||||
default:
|
||||
m_opLinkType = OPLINK_UNKNOWN;
|
||||
// disconnect if connected
|
||||
onOPLinkDisconnect();
|
||||
// and start monitoring OPLinkStatus to see if a board shows up
|
||||
connect(m_opLinkStatus, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(onOPLinkStatusUpdate()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OPLinkManager::onOPLinkConnect()
|
||||
{
|
||||
if (m_isConnected) {
|
||||
return;
|
||||
}
|
||||
// stop listening to status updates...
|
||||
m_opLinkStatus->disconnect(this);
|
||||
|
||||
m_isConnected = true;
|
||||
emit connected();
|
||||
}
|
||||
|
||||
void OPLinkManager::onOPLinkDisconnect()
|
||||
{
|
||||
if (!m_isConnected) {
|
||||
return;
|
||||
}
|
||||
// stop listening to status updates...
|
||||
m_opLinkStatus->disconnect(this);
|
||||
|
||||
m_isConnected = false;
|
||||
emit disconnected();
|
||||
}
|
94
ground/gcs/src/plugins/uavtalk/oplinkmanager.h
Normal file
94
ground/gcs/src/plugins/uavtalk/oplinkmanager.h
Normal file
@ -0,0 +1,94 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file oplinkmanager.h
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup UAVTalkPlugin UAVTalk Plugin
|
||||
* @{
|
||||
* @brief The UAVTalk protocol plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef OPLINK_MANAGER_H
|
||||
#define OPLINK_MANAGER_H
|
||||
|
||||
#include "uavtalk_global.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class OPLinkStatus;
|
||||
|
||||
class UAVTALK_EXPORT OPLinkManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum OPLinkType {
|
||||
OPLINK_UNKNOWN,
|
||||
OPLINK_MINI,
|
||||
OPLINK_REVOLUTION
|
||||
};
|
||||
|
||||
OPLinkManager();
|
||||
~OPLinkManager();
|
||||
|
||||
OPLinkManager::OPLinkType opLinkType() const
|
||||
{
|
||||
return m_opLinkType;
|
||||
}
|
||||
|
||||
// void start(QIODevice *dev);
|
||||
// void stop();
|
||||
bool isConnected() const;
|
||||
// ConnectionState connectionState() const;
|
||||
|
||||
signals:
|
||||
// void connecting();
|
||||
void connected();
|
||||
// void disconnecting();
|
||||
void disconnected();
|
||||
// void telemetryUpdated(double txRate, double rxRate);
|
||||
// void myStart();
|
||||
// void myStop();
|
||||
|
||||
private slots:
|
||||
// void onConnect();
|
||||
// void onDisconnect();
|
||||
void onDeviceConnect();
|
||||
void onDeviceDisconnect();
|
||||
void onOPLinkStatusUpdate();
|
||||
void onOPLinkConnect();
|
||||
void onOPLinkDisconnect();
|
||||
// void onOPLinkUpdate(double txRate, double rxRate);
|
||||
// void onStart();
|
||||
// void onStop();
|
||||
|
||||
private:
|
||||
// UAVObjectManager *m_uavobjectManager;
|
||||
// UAVTalk *m_uavTalk;
|
||||
// OPLink *m_telemetry;
|
||||
// OPLinkMonitor *m_telemetryMonitor;
|
||||
// QIODevice *m_telemetryDevice;
|
||||
// ConnectionState m_connectionState;
|
||||
// QThread m_telemetryReaderThread;
|
||||
bool m_isConnected;
|
||||
OPLinkType m_opLinkType;
|
||||
OPLinkStatus *m_opLinkStatus;
|
||||
};
|
||||
|
||||
#endif // OPLINK_MANAGER_H
|
@ -2,7 +2,8 @@
|
||||
******************************************************************************
|
||||
*
|
||||
* @file telemetrymanager.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup UAVTalkPlugin UAVTalk Plugin
|
||||
@ -32,9 +33,10 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/threadmanager.h>
|
||||
|
||||
TelemetryManager::TelemetryManager() : m_connectionState(TELEMETRY_DISCONNECTED)
|
||||
TelemetryManager::TelemetryManager() : QObject(), m_connectionState(TELEMETRY_DISCONNECTED)
|
||||
{
|
||||
moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread());
|
||||
|
||||
// Get UAVObjectManager instance
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
m_uavobjectManager = pm->getObject<UAVObjectManager>();
|
||||
|
@ -1,8 +1,9 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file telemetrymanager.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @file telemetrymanager.h
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup UAVTalkPlugin UAVTalk Plugin
|
||||
@ -25,8 +26,8 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef TELEMETRYMANAGER_H
|
||||
#define TELEMETRYMANAGER_H
|
||||
#ifndef TELEMETRY_MANAGER_H
|
||||
#define TELEMETRY_MANAGER_H
|
||||
|
||||
#include "uavtalk_global.h"
|
||||
#include "uavtalk.h"
|
||||
@ -94,4 +95,4 @@ public slots:
|
||||
void read();
|
||||
};
|
||||
|
||||
#endif // TELEMETRYMANAGER_H
|
||||
#endif // TELEMETRY_MANAGER_H
|
||||
|
@ -2,7 +2,8 @@
|
||||
******************************************************************************
|
||||
*
|
||||
* @file telemetrymonitor.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup UAVTalkPlugin UAVTalk Plugin
|
||||
@ -88,8 +89,7 @@ void TelemetryMonitor::startRetrievingObjects()
|
||||
}
|
||||
}
|
||||
// Start retrieving
|
||||
qDebug() << tr("Starting to retrieve meta and settings objects from the autopilot (%1 objects)")
|
||||
.arg(queue.length());
|
||||
qDebug() << "TelemetryMonitor::startRetrievingObjects() - retrieving" << queue.length() << "objects";
|
||||
retrieveNextObject();
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ void TelemetryMonitor::retrieveNextObject()
|
||||
{
|
||||
// If queue is empty return
|
||||
if (queue.isEmpty()) {
|
||||
qDebug("Object retrieval completed");
|
||||
qDebug() << "TelemetryMonitor::retrieveNextObject - Object retrieval completed";
|
||||
if (firmwareIAPObj->getBoardType()) {
|
||||
emit connected();
|
||||
} else {
|
||||
@ -142,14 +142,16 @@ void TelemetryMonitor::transactionCompleted(UAVObject *obj, bool success)
|
||||
// Disconnect from sending object
|
||||
obj->disconnect(this);
|
||||
objPending = NULL;
|
||||
|
||||
// Process next object if telemetry is still available
|
||||
GCSTelemetryStats::DataFields gcsStats = gcsStatsObj->getData();
|
||||
|
||||
if (gcsStats.Status == GCSTelemetryStats::STATUS_CONNECTED) {
|
||||
retrieveNextObject();
|
||||
} else {
|
||||
stopRetrievingObjects();
|
||||
}
|
||||
} else {
|
||||
qCritical() << "TelemetryMonitor::retrieveNextObject - unexpected object" << obj;
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,13 +254,12 @@ void TelemetryMonitor::processStatsUpdates()
|
||||
// Act on new connections or disconnections
|
||||
if (gcsStats.Status == GCSTelemetryStats::STATUS_CONNECTED && gcsStats.Status != oldStatus) {
|
||||
statsTimer->setInterval(STATS_UPDATE_PERIOD_MS);
|
||||
qDebug("Connection with the autopilot established");
|
||||
qDebug() << "TelemetryMonitor::processStatsUpdates() - connection with the autopilot established";
|
||||
startRetrievingObjects();
|
||||
}
|
||||
if (gcsStats.Status == GCSTelemetryStats::STATUS_DISCONNECTED && gcsStats.Status != oldStatus) {
|
||||
statsTimer->setInterval(STATS_CONNECT_PERIOD_MS);
|
||||
qDebug("Connection with the autopilot lost");
|
||||
qDebug("Trying to connect to the autopilot");
|
||||
qDebug() << "TelemetryMonitor::processStatsUpdates() - Connection with the autopilot lost";
|
||||
emit disconnected();
|
||||
}
|
||||
}
|
||||
|
@ -12,18 +12,20 @@ include(../../plugin.pri)
|
||||
include(uavtalk_dependencies.pri)
|
||||
|
||||
HEADERS += \
|
||||
uavtalk_global.h \
|
||||
uavtalk.h \
|
||||
uavtalkplugin.h \
|
||||
telemetry.h \
|
||||
telemetrymonitor.h \
|
||||
telemetrymanager.h \
|
||||
uavtalk_global.h \
|
||||
telemetry.h
|
||||
oplinkmanager.h \
|
||||
uavtalkplugin.h
|
||||
|
||||
SOURCES += \
|
||||
uavtalk.cpp \
|
||||
uavtalkplugin.cpp \
|
||||
telemetry.cpp \
|
||||
telemetrymonitor.cpp \
|
||||
telemetrymanager.cpp \
|
||||
telemetry.cpp
|
||||
oplinkmanager.cpp \
|
||||
uavtalkplugin.cpp
|
||||
|
||||
OTHER_FILES += UAVTalk.pluginspec
|
||||
|
@ -2,7 +2,8 @@
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavtalkplugin.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup UAVTalkPlugin UAVTalk Plugin
|
||||
@ -26,14 +27,18 @@
|
||||
*/
|
||||
#include "uavtalkplugin.h"
|
||||
|
||||
#include "telemetrymanager.h"
|
||||
#include "oplinkmanager.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/connectionmanager.h>
|
||||
|
||||
UAVTalkPlugin::UAVTalkPlugin()
|
||||
UAVTalkPlugin::UAVTalkPlugin() : telemetryManager(0)
|
||||
{}
|
||||
|
||||
UAVTalkPlugin::~UAVTalkPlugin()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Called once all the plugins which depend on us have been loaded
|
||||
*/
|
||||
@ -50,15 +55,18 @@ bool UAVTalkPlugin::initialize(const QStringList & arguments, QString *errorStri
|
||||
Q_UNUSED(errorString);
|
||||
|
||||
// Create TelemetryManager
|
||||
telMngr = new TelemetryManager();
|
||||
addAutoReleasedObject(telMngr);
|
||||
telemetryManager = new TelemetryManager();
|
||||
addAutoReleasedObject(telemetryManager);
|
||||
|
||||
// Create OPLinkManager
|
||||
OPLinkManager *opLinkManager = new OPLinkManager();
|
||||
addAutoReleasedObject(opLinkManager);
|
||||
|
||||
// Connect to connection manager so we get notified when the user connect to his device
|
||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||
QObject::connect(cm, SIGNAL(deviceConnected(QIODevice *)),
|
||||
this, SLOT(onDeviceConnect(QIODevice *)));
|
||||
QObject::connect(cm, SIGNAL(deviceAboutToDisconnect()),
|
||||
this, SLOT(onDeviceDisconnect()));
|
||||
QObject::connect(cm, SIGNAL(deviceConnected(QIODevice *)), this, SLOT(onDeviceConnect(QIODevice *)));
|
||||
QObject::connect(cm, SIGNAL(deviceAboutToDisconnect()), this, SLOT(onDeviceDisconnect()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -67,10 +75,10 @@ void UAVTalkPlugin::shutdown()
|
||||
|
||||
void UAVTalkPlugin::onDeviceConnect(QIODevice *dev)
|
||||
{
|
||||
telMngr->start(dev);
|
||||
telemetryManager->start(dev);
|
||||
}
|
||||
|
||||
void UAVTalkPlugin::onDeviceDisconnect()
|
||||
{
|
||||
telMngr->stop();
|
||||
telemetryManager->stop();
|
||||
}
|
||||
|
@ -2,7 +2,8 @@
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavtalkplugin.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016.
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup UAVTalkPlugin UAVTalk Plugin
|
||||
@ -28,10 +29,9 @@
|
||||
#define UAVTALKPLUGIN_H
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <QtPlugin>
|
||||
#include "uavtalk.h"
|
||||
#include "telemetrymanager.h"
|
||||
|
||||
class TelemetryManager;
|
||||
|
||||
class UAVTALK_EXPORT UAVTalkPlugin : public ExtensionSystem::IPlugin {
|
||||
Q_OBJECT
|
||||
@ -50,7 +50,7 @@ protected slots:
|
||||
void onDeviceDisconnect();
|
||||
|
||||
private:
|
||||
TelemetryManager *telMngr;
|
||||
TelemetryManager *telemetryManager;
|
||||
};
|
||||
|
||||
#endif // UAVTALKPLUGIN_H
|
||||
|
@ -1,90 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file oplinkwatchdog.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @addtogroup [Group]
|
||||
* @{
|
||||
* @addtogroup OPLinkWatchdog
|
||||
* @{
|
||||
* @brief [Brief]
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "oplinkwatchdog.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjects/uavobjectmanager.h"
|
||||
#include "oplinkstatus.h"
|
||||
#include <QDebug>
|
||||
|
||||
OPLinkWatchdog::OPLinkWatchdog() : QObject(),
|
||||
m_isConnected(false)
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
|
||||
Q_ASSERT(pm);
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objManager);
|
||||
m_opLinkStatus = OPLinkStatus::GetInstance(objManager);
|
||||
Q_ASSERT(m_opLinkStatus);
|
||||
connect(m_opLinkStatus, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(onOPLinkStatusUpdate()));
|
||||
m_watchdog = new QTimer(this);
|
||||
connect(m_watchdog, SIGNAL(timeout()), this, SLOT(onTimeout()));
|
||||
onOPLinkStatusUpdate();
|
||||
}
|
||||
|
||||
OPLinkWatchdog::~OPLinkWatchdog()
|
||||
{}
|
||||
|
||||
void OPLinkWatchdog::onOPLinkStatusUpdate()
|
||||
{
|
||||
m_watchdog->stop();
|
||||
quint8 type = m_opLinkStatus->getBoardType();
|
||||
if (!m_isConnected) {
|
||||
switch (type) {
|
||||
case 3:
|
||||
m_opLinkType = OPLINK_MINI;
|
||||
m_isConnected = true;
|
||||
emit connected();
|
||||
emit opLinkMiniConnected();
|
||||
break;
|
||||
case 9:
|
||||
m_opLinkType = OPLINK_REVOLUTION;
|
||||
m_isConnected = true;
|
||||
emit connected();
|
||||
emit opLinkRevolutionConnected();
|
||||
break;
|
||||
default:
|
||||
m_isConnected = false;
|
||||
m_opLinkType = OPLINK_UNKNOWN;
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "OPLinkWatchdog - OPLink connected";
|
||||
}
|
||||
m_watchdog->start(m_opLinkStatus->getMetadata().flightTelemetryUpdatePeriod * 3);
|
||||
}
|
||||
|
||||
void OPLinkWatchdog::onTimeout()
|
||||
{
|
||||
if (m_isConnected) {
|
||||
m_isConnected = false;
|
||||
m_opLinkType = OPLINK_UNKNOWN;
|
||||
qDebug() << "OPLinkWatchdog - OPLink disconnected";
|
||||
emit disconnected();
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file oplinkwatchdog.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @addtogroup [Group]
|
||||
* @{
|
||||
* @addtogroup OPLinkWatchdog
|
||||
* @{
|
||||
* @brief [Brief]
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef OPLINKWATCHDOG_H
|
||||
#define OPLINKWATCHDOG_H
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
class OPLinkStatus;
|
||||
class OPLinkWatchdog : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum OPLinkType {
|
||||
OPLINK_MINI,
|
||||
OPLINK_REVOLUTION,
|
||||
OPLINK_UNKNOWN
|
||||
};
|
||||
|
||||
OPLinkWatchdog();
|
||||
~OPLinkWatchdog();
|
||||
bool isConnected() const
|
||||
{
|
||||
return m_isConnected;
|
||||
}
|
||||
OPLinkWatchdog::OPLinkType opLinkType() const
|
||||
{
|
||||
return m_opLinkType;
|
||||
}
|
||||
|
||||
signals:
|
||||
void connected();
|
||||
void opLinkMiniConnected();
|
||||
void opLinkRevolutionConnected();
|
||||
void disconnected();
|
||||
|
||||
private slots:
|
||||
void onOPLinkStatusUpdate();
|
||||
void onTimeout();
|
||||
|
||||
private:
|
||||
bool m_isConnected;
|
||||
OPLinkType m_opLinkType;
|
||||
QTimer *m_watchdog;
|
||||
OPLinkStatus *m_opLinkStatus;
|
||||
};
|
||||
#endif // OPLINKWATCHDOG_H
|
@ -33,8 +33,7 @@ HEADERS += \
|
||||
runningdevicewidget.h \
|
||||
uploader_global.h \
|
||||
enums.h \
|
||||
rebootdialog.h \
|
||||
oplinkwatchdog.h
|
||||
rebootdialog.h
|
||||
|
||||
SOURCES += \
|
||||
uploadergadget.cpp \
|
||||
@ -50,8 +49,7 @@ SOURCES += \
|
||||
SSP/qssp.cpp \
|
||||
SSP/qsspt.cpp \
|
||||
runningdevicewidget.cpp \
|
||||
rebootdialog.cpp \
|
||||
oplinkwatchdog.cpp
|
||||
rebootdialog.cpp
|
||||
|
||||
OTHER_FILES += Uploader.pluginspec
|
||||
|
||||
|
@ -2,7 +2,8 @@
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uploadergadgetoptionspage.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup YModemUploader YModem Serial Uploader Plugin
|
||||
@ -26,7 +27,9 @@
|
||||
*/
|
||||
|
||||
#include "uploadergadgetoptionspage.h"
|
||||
|
||||
#include "uploadergadgetconfiguration.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QSpinBox>
|
||||
#include <QDoubleSpinBox>
|
||||
|
@ -2,7 +2,8 @@
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uploadergadgetoptionspage.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup YModemUploader YModem Serial Uploader Plugin
|
||||
@ -27,19 +28,19 @@
|
||||
|
||||
#ifndef UPLOADERGADGETOPTIONSPAGE_H
|
||||
#define UPLOADERGADGETOPTIONSPAGE_H
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
|
||||
#include "uploader_global.h"
|
||||
#include "coreplugin/dialogs/ioptionspage.h"
|
||||
#include "QString"
|
||||
|
||||
#include <QEventLoop>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
#include "uploader_global.h"
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
|
||||
namespace Core {
|
||||
class IUAVGadgetConfiguration;
|
||||
}
|
||||
class UploaderGadgetConfiguration;
|
||||
class QTextEdit;
|
||||
|
||||
class QComboBox;
|
||||
class QSpinBox;
|
||||
|
||||
|
@ -27,8 +27,9 @@
|
||||
*/
|
||||
#include "uploadergadgetwidget.h"
|
||||
|
||||
#include "ui_uploader.h"
|
||||
|
||||
#include "flightstatus.h"
|
||||
#include "oplinkstatus.h"
|
||||
#include "delay.h"
|
||||
#include "devicewidget.h"
|
||||
#include "runningdevicewidget.h"
|
||||
@ -38,12 +39,13 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/connectionmanager.h>
|
||||
#include <uavtalk/telemetrymanager.h>
|
||||
#include <uavtalk/oplinkmanager.h>
|
||||
#include "rebootdialog.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
#include <QProgressBar>
|
||||
#include <QDebug>
|
||||
#include "rebootdialog.h"
|
||||
|
||||
#define DFU_DEBUG true
|
||||
|
||||
@ -675,16 +677,21 @@ bool UploaderGadgetWidget::autoUpdateCapable()
|
||||
|
||||
bool UploaderGadgetWidget::autoUpdate(bool erase)
|
||||
{
|
||||
if (m_oplinkwatchdog.isConnected() &&
|
||||
m_oplinkwatchdog.opLinkType() == OPLinkWatchdog::OPLINK_MINI) {
|
||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||
|
||||
Q_ASSERT(pluginManager);
|
||||
|
||||
OPLinkManager *opLinkManager = pluginManager->getObject<OPLinkManager>();
|
||||
Q_ASSERT(opLinkManager);
|
||||
|
||||
if (opLinkManager->isConnected() &&
|
||||
opLinkManager->opLinkType() == OPLinkManager::OPLINK_MINI) {
|
||||
emit progressUpdate(FAILURE, QVariant(tr("To upgrade the OPLinkMini board please disconnect it from the USB port, "
|
||||
"press the Upgrade again button and follow instructions on screen.")));
|
||||
emit autoUpdateFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||
Q_ASSERT(pluginManager);
|
||||
TelemetryManager *telemetryManager = pluginManager->getObject<TelemetryManager>();
|
||||
Q_ASSERT(telemetryManager);
|
||||
|
||||
@ -824,11 +831,11 @@ bool UploaderGadgetWidget::autoUpdate(bool erase)
|
||||
// Wait for board to connect to GCS again after boot and erase
|
||||
// For older board like CC3D this can take some time
|
||||
// Theres a special case with OPLink
|
||||
if (!telemetryManager->isConnected() && !m_oplinkwatchdog.isConnected()) {
|
||||
if (!telemetryManager->isConnected() && !opLinkManager->isConnected()) {
|
||||
progressUpdate(erase ? BOOTING_AND_ERASING : BOOTING, QVariant());
|
||||
ResultEventLoop eventLoop;
|
||||
connect(telemetryManager, SIGNAL(connected()), &eventLoop, SLOT(success()));
|
||||
connect(&m_oplinkwatchdog, SIGNAL(opLinkMiniConnected()), &eventLoop, SLOT(success()));
|
||||
connect(opLinkManager, SIGNAL(connected()), &eventLoop, SLOT(success()));
|
||||
|
||||
if (eventLoop.run(REBOOT_TIMEOUT + (erase ? ERASE_TIMEOUT : 0)) != 0) {
|
||||
emit progressUpdate(FAILURE, QVariant(tr("Timed out while booting.")));
|
||||
@ -836,7 +843,7 @@ bool UploaderGadgetWidget::autoUpdate(bool erase)
|
||||
return false;
|
||||
}
|
||||
|
||||
disconnect(&m_oplinkwatchdog, SIGNAL(opLinkMiniConnected()), &eventLoop, SLOT(success()));
|
||||
disconnect(opLinkManager, SIGNAL(connected()), &eventLoop, SLOT(success()));
|
||||
disconnect(telemetryManager, SIGNAL(connected()), &eventLoop, SLOT(success()));
|
||||
}
|
||||
|
||||
|
@ -28,22 +28,21 @@
|
||||
#ifndef UPLOADERGADGETWIDGET_H
|
||||
#define UPLOADERGADGETWIDGET_H
|
||||
|
||||
#include "ui_uploader.h"
|
||||
#include "uploader_global.h"
|
||||
|
||||
#include "enums.h"
|
||||
#include "op_dfu.h"
|
||||
|
||||
#include <QEventLoop>
|
||||
#include <QProgressDialog>
|
||||
#include "oplinkwatchdog.h"
|
||||
|
||||
using namespace OP_DFU;
|
||||
using namespace uploader;
|
||||
|
||||
class Ui_UploaderWidget;
|
||||
|
||||
class FlightStatus;
|
||||
class UAVObject;
|
||||
class OPLinkStatus;
|
||||
class OPLinkWatchdog;
|
||||
|
||||
class TimedDialog : public QProgressDialog {
|
||||
Q_OBJECT
|
||||
@ -146,7 +145,6 @@ private:
|
||||
DFUObject *m_dfu;
|
||||
IAPStep m_currentIAPStep;
|
||||
bool m_resetOnly;
|
||||
OPLinkWatchdog m_oplinkwatchdog;
|
||||
bool m_autoUpdateClosing;
|
||||
|
||||
void clearLog();
|
||||
|
Loading…
x
Reference in New Issue
Block a user