mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
OP-1174 moved firmware version check (again) from uploader plugin to telemetry plugin
This commit is contained in:
parent
6fe1c9acd2
commit
8c0560418d
@ -5,6 +5,7 @@ QT += svg
|
|||||||
|
|
||||||
include(../../openpilotgcsplugin.pri)
|
include(../../openpilotgcsplugin.pri)
|
||||||
include(../../plugins/coreplugin/coreplugin.pri)
|
include(../../plugins/coreplugin/coreplugin.pri)
|
||||||
|
include(../../libs/version_info/version_info.pri)
|
||||||
include(telemetry_dependencies.pri)
|
include(telemetry_dependencies.pri)
|
||||||
|
|
||||||
HEADERS += telemetry_global.h \
|
HEADERS += telemetry_global.h \
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
include(../../plugins/uavtalk/uavtalk.pri)
|
|
||||||
include(../../plugins/uavobjects/uavobjects.pri)
|
include(../../plugins/uavobjects/uavobjects.pri)
|
||||||
|
include(../../plugins/uavobjectutil/uavobjectutil.pri)
|
||||||
|
include(../../plugins/uavtalk/uavtalk.pri)
|
||||||
|
|
||||||
|
@ -28,22 +28,27 @@
|
|||||||
#include "telemetryplugin.h"
|
#include "telemetryplugin.h"
|
||||||
#include "monitorgadgetfactory.h"
|
#include "monitorgadgetfactory.h"
|
||||||
|
|
||||||
#include "extensionsystem/pluginmanager.h"
|
#include "version_info/version_info.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include "coreplugin/icore.h"
|
#include "uavobjectutilmanager.h"
|
||||||
#include "coreplugin/connectionmanager.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QtPlugin>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/iuavgadget.h>
|
#include <coreplugin/iuavgadget.h>
|
||||||
|
#include <coreplugin/connectionmanager.h>
|
||||||
|
#include <uavtalk/telemetrymanager.h>
|
||||||
|
|
||||||
TelemetryPlugin::TelemetryPlugin()
|
#include <QDebug>
|
||||||
{}
|
#include <QStringList>
|
||||||
|
#include <QErrorMessage>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
TelemetryPlugin::TelemetryPlugin() : errorMsg(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
TelemetryPlugin::~TelemetryPlugin()
|
TelemetryPlugin::~TelemetryPlugin()
|
||||||
{
|
{
|
||||||
@ -81,166 +86,70 @@ bool TelemetryPlugin::initialize(const QStringList & args, QString *errMsg)
|
|||||||
|
|
||||||
// add monitor widget to connection manager
|
// add monitor widget to connection manager
|
||||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||||
// connect(cm, SIGNAL(deviceConnected(QIODevice *)), w, SLOT(telemetryConnected()));
|
|
||||||
// connect(cm, SIGNAL(deviceDisconnected()), w, SLOT(telemetryDisconnected()));
|
|
||||||
|
|
||||||
cm->addWidget(w);
|
cm->addWidget(w);
|
||||||
|
|
||||||
|
// Listen to autopilot connection events
|
||||||
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
|
TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
|
||||||
|
connect(telMngr, SIGNAL(connected()), this, SLOT(versionMatchCheck()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPlugin::extensionsInitialized()
|
void TelemetryPlugin::extensionsInitialized()
|
||||||
{
|
|
||||||
// Core::ICore::instance()->readSettings(this);
|
|
||||||
|
|
||||||
// ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
||||||
|
|
||||||
// connect(pm, SIGNAL(objectAdded(QObject *)), this, SLOT(onTelemetryManagerAdded(QObject *)));
|
|
||||||
// _toRemoveNotifications.clear();
|
|
||||||
// connectNotifications();
|
|
||||||
}
|
|
||||||
|
|
||||||
// void TelemetryPlugin::saveConfig(QSettings *settings, UAVConfigInfo *configInfo)
|
|
||||||
// {
|
|
||||||
// configInfo->setVersion(VERSION);
|
|
||||||
//
|
|
||||||
// settings->beginWriteArray("Current");
|
|
||||||
// settings->setArrayIndex(0);
|
|
||||||
// currentNotification.saveState(settings);
|
|
||||||
// settings->endArray();
|
|
||||||
//
|
|
||||||
// settings->beginGroup("listNotifies");
|
|
||||||
// settings->remove("");
|
|
||||||
// settings->endGroup();
|
|
||||||
//
|
|
||||||
// settings->beginWriteArray("listNotifies");
|
|
||||||
// for (int i = 0; i < _notificationList.size(); i++) {
|
|
||||||
// settings->setArrayIndex(i);
|
|
||||||
// _notificationList.at(i)->saveState(settings);
|
|
||||||
// }
|
|
||||||
// settings->endArray();
|
|
||||||
// settings->setValue(QLatin1String("Enable"), enable);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void TelemetryPlugin::readConfig(QSettings *settings, UAVConfigInfo * /* configInfo */)
|
|
||||||
// {
|
|
||||||
//// Just for migration to the new format.
|
|
||||||
//// Q_ASSERT(configInfo->version() == UAVConfigVersion());
|
|
||||||
//
|
|
||||||
// settings->beginReadArray("Current");
|
|
||||||
// settings->setArrayIndex(0);
|
|
||||||
// currentNotification.restoreState(settings);
|
|
||||||
// settings->endArray();
|
|
||||||
//
|
|
||||||
//// read list of notifications from settings
|
|
||||||
// int size = settings->beginReadArray("listNotifies");
|
|
||||||
// for (int i = 0; i < size; ++i) {
|
|
||||||
// settings->setArrayIndex(i);
|
|
||||||
// NotificationItem *notification = new NotificationItem;
|
|
||||||
// notification->restoreState(settings);
|
|
||||||
// _notificationList.append(notification);
|
|
||||||
// }
|
|
||||||
// settings->endArray();
|
|
||||||
// setEnable(settings->value(QLatin1String("Enable"), 0).toBool());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void TelemetryPlugin::onTelemetryManagerAdded(QObject *obj)
|
|
||||||
// {
|
|
||||||
// telMngr = qobject_cast<TelemetryManager *>(obj);
|
|
||||||
// if (telMngr) {
|
|
||||||
// connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect()));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
void TelemetryPlugin::shutdown()
|
|
||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
// void TelemetryPlugin::onAutopilotDisconnect()
|
void TelemetryPlugin::shutdown()
|
||||||
// {
|
{
|
||||||
// connectNotifications();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
// }
|
TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
|
||||||
|
disconnect(telMngr, SIGNAL(connected()), this, SLOT(versionMatchCheck()));
|
||||||
|
}
|
||||||
|
|
||||||
///*!
|
void TelemetryPlugin::versionMatchCheck()
|
||||||
// clear any telemetry timers from previous flight;
|
{
|
||||||
// reset will be perform on start of option page
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
// */
|
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
|
||||||
// void TelemetryPlugin::resetNotification(void)
|
deviceDescriptorStruct boardDescription = utilMngr->getBoardDescriptionStruct();
|
||||||
// {
|
|
||||||
//// first, reject empty args and unknown fields.
|
|
||||||
// foreach(NotificationItem * ntf, _notificationList) {
|
|
||||||
// ntf->disposeTimer();
|
|
||||||
// disconnect(ntf->getTimer(), SIGNAL(timeout()), this, SLOT(on_timerRepeated_Notification()));
|
|
||||||
// ntf->disposeExpireTimer();
|
|
||||||
// disconnect(ntf->getExpireTimer(), SIGNAL(timeout()), this, SLOT(on_timerRepeated_Notification()));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void TelemetryPlugin::connectNotifications()
|
QString uavoHash = VersionInfo::uavoHashArray();
|
||||||
// {
|
uavoHash.chop(2);
|
||||||
// foreach(UAVDataObject * obj, lstNotifiedUAVObjects) {
|
uavoHash.remove(0, 2);
|
||||||
// if (obj != NULL) {
|
uavoHash = uavoHash.trimmed();
|
||||||
// disconnect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(on_arrived_Notification(UAVObject *)));
|
|
||||||
// }
|
QByteArray uavoHashArray;
|
||||||
// }
|
bool ok;
|
||||||
// if (phonon.mo != NULL) {
|
foreach(QString str, uavoHash.split(",")) {
|
||||||
// delete phonon.mo;
|
uavoHashArray.append(str.toInt(&ok, 16));
|
||||||
// phonon.mo = NULL;
|
}
|
||||||
// }
|
|
||||||
//
|
QByteArray fwVersion = boardDescription.uavoHash;
|
||||||
// if (!enable) {
|
if (fwVersion != uavoHashArray) {
|
||||||
// return;
|
QString gcsDescription = VersionInfo::revision();
|
||||||
// }
|
QString gcsGitHash = gcsDescription.mid(gcsDescription.indexOf(":") + 1, 8);
|
||||||
//
|
gcsGitHash.remove(QRegExp("^[0]*"));
|
||||||
// ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
QString gcsGitDate = gcsDescription.mid(gcsDescription.indexOf(" ") + 1, 14);
|
||||||
// UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
|
||||||
//
|
QString gcsUavoHashStr;
|
||||||
// lstNotifiedUAVObjects.clear();
|
QString fwUavoHashStr;
|
||||||
// _pendingNotifications.clear();
|
foreach(char i, fwVersion) {
|
||||||
// _notificationList.append(_toRemoveNotifications);
|
fwUavoHashStr.append(QString::number(i, 16).right(2));
|
||||||
// _toRemoveNotifications.clear();
|
}
|
||||||
//
|
foreach(char i, uavoHashArray) {
|
||||||
//// first, reject empty args and unknown fields.
|
gcsUavoHashStr.append(QString::number(i, 16).right(2));
|
||||||
// foreach(NotificationItem * telemetry, _notificationList) {
|
}
|
||||||
// telemetry->_isPlayed = false;
|
QString gcsVersion = gcsGitDate + " (" + gcsGitHash + "-" + gcsUavoHashStr.left(8) + ")";
|
||||||
// telemetry->isNowPlaying = false;
|
QString fwVersion = boardDescription.gitDate + " (" + boardDescription.gitHash + "-" + fwUavoHashStr.left(8) + ")";
|
||||||
//
|
|
||||||
// if (telemetry->mute()) {
|
QString warning = QString(tr(
|
||||||
// continue;
|
"GCS and firmware versions of the UAV objects set do not match which can cause configuration problems. "
|
||||||
// }
|
"GCS version: %1 Firmware version: %2.")).arg(gcsVersion).arg(fwVersion);
|
||||||
//// check is all sounds presented for notification,
|
if (!errorMsg) {
|
||||||
//// if not - we must not subscribe to it at all
|
errorMsg = new QErrorMessage(Core::ICore::instance()->mainWindow());
|
||||||
// if (telemetry->toList().isEmpty()) {
|
}
|
||||||
// continue;
|
errorMsg->showMessage(warning);
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// UAVDataObject *obj = dynamic_cast<UAVDataObject *>(objManager->getObject(telemetry->getDataObject()));
|
|
||||||
// if (obj != NULL) {
|
|
||||||
// if (!lstNotifiedUAVObjects.contains(obj)) {
|
|
||||||
// lstNotifiedUAVObjects.append(obj);
|
|
||||||
//
|
|
||||||
// connect(obj, SIGNAL(objectUpdated(UAVObject *)),
|
|
||||||
// this, SLOT(on_arrived_Notification(UAVObject *)),
|
|
||||||
// Qt::QueuedConnection);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// qTelemetryDebug() << "Error: Object is unknown (" << telemetry->getDataObject() << ").";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (_notificationList.isEmpty()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//// set notification message to current event
|
|
||||||
// phonon.mo = Phonon::createPlayer(Phonon::NotificationCategory);
|
|
||||||
// phonon.mo->clearQueue();
|
|
||||||
// phonon.firstPlay = true;
|
|
||||||
// QList<Phonon::AudioOutputDevice> audioOutputDevices =
|
|
||||||
// Phonon::BackendCapabilities::availableAudioOutputDevices();
|
|
||||||
// foreach(Phonon::AudioOutputDevice dev, audioOutputDevices) {
|
|
||||||
// qTelemetryDebug() << "Telemetry: Audio Output device: " << dev.name() << " - " << dev.description();
|
|
||||||
// }
|
|
||||||
// connect(phonon.mo, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
|
|
||||||
// this, SLOT(stateChanged(Phonon::State, Phonon::State)));
|
|
||||||
// }
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
|
class QErrorMessage;
|
||||||
class MonitorGadgetFactory;
|
class MonitorGadgetFactory;
|
||||||
|
|
||||||
class TelemetryPlugin : public ExtensionSystem::IPlugin {
|
class TelemetryPlugin : public ExtensionSystem::IPlugin {
|
||||||
@ -44,8 +45,12 @@ public:
|
|||||||
bool initialize(const QStringList &arguments, QString *errorString);
|
bool initialize(const QStringList &arguments, QString *errorString);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void versionMatchCheck();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MonitorGadgetFactory *mf;
|
MonitorGadgetFactory *mf;
|
||||||
|
QErrorMessage *errorMsg;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TELEMETRYPLUGIN_H
|
#endif // TELEMETRYPLUGIN_H
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
include(../../openpilotgcsplugin.pri)
|
include(../../openpilotgcsplugin.pri)
|
||||||
include(../../plugins/coreplugin/coreplugin.pri)
|
include(../../plugins/coreplugin/coreplugin.pri)
|
||||||
include(../../plugins/uavobjects/uavobjects.pri)
|
include(../../plugins/uavobjects/uavobjects.pri)
|
||||||
|
include(../../plugins/uavobjectutil/uavobjectutil.pri)
|
||||||
include(../../plugins/uavtalk/uavtalk.pri)
|
include(../../plugins/uavtalk/uavtalk.pri)
|
||||||
include(../../plugins/ophid/ophid.pri)
|
include(../../plugins/ophid/ophid.pri)
|
||||||
include(../../plugins/uavobjectutil/uavobjectutil.pri)
|
|
||||||
|
@ -27,20 +27,11 @@
|
|||||||
#include "uploaderplugin.h"
|
#include "uploaderplugin.h"
|
||||||
#include "uploadergadgetfactory.h"
|
#include "uploadergadgetfactory.h"
|
||||||
|
|
||||||
#include "version_info/version_info.h"
|
|
||||||
#include "devicedescriptorstruct.h"
|
|
||||||
#include "uavobjectutilmanager.h"
|
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <uavtalk/telemetrymanager.h>
|
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QErrorMessage>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QMainWindow>
|
|
||||||
|
|
||||||
UploaderPlugin::UploaderPlugin() : errorMsg(0)
|
UploaderPlugin::UploaderPlugin()
|
||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
@ -58,11 +49,6 @@ bool UploaderPlugin::initialize(const QStringList & args, QString *errMsg)
|
|||||||
mf = new UploaderGadgetFactory(this);
|
mf = new UploaderGadgetFactory(this);
|
||||||
addAutoReleasedObject(mf);
|
addAutoReleasedObject(mf);
|
||||||
|
|
||||||
// Listen to autopilot connection events
|
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
||||||
TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
|
|
||||||
connect(telMngr, SIGNAL(connected()), this, SLOT(versionMatchCheck()));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,52 +59,5 @@ void UploaderPlugin::extensionsInitialized()
|
|||||||
|
|
||||||
void UploaderPlugin::shutdown()
|
void UploaderPlugin::shutdown()
|
||||||
{
|
{
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
// Do nothing
|
||||||
TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
|
|
||||||
disconnect(telMngr, SIGNAL(connected()), this, SLOT(versionMatchCheck()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UploaderPlugin::versionMatchCheck()
|
|
||||||
{
|
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
||||||
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
|
|
||||||
deviceDescriptorStruct boardDescription = utilMngr->getBoardDescriptionStruct();
|
|
||||||
|
|
||||||
QString uavoHash = VersionInfo::uavoHashArray();
|
|
||||||
uavoHash.chop(2);
|
|
||||||
uavoHash.remove(0, 2);
|
|
||||||
uavoHash = uavoHash.trimmed();
|
|
||||||
|
|
||||||
QByteArray uavoHashArray;
|
|
||||||
bool ok;
|
|
||||||
foreach(QString str, uavoHash.split(",")) {
|
|
||||||
uavoHashArray.append(str.toInt(&ok, 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray fwVersion = boardDescription.uavoHash;
|
|
||||||
if (fwVersion != uavoHashArray) {
|
|
||||||
QString gcsDescription = VersionInfo::revision();
|
|
||||||
QString gcsGitHash = gcsDescription.mid(gcsDescription.indexOf(":") + 1, 8);
|
|
||||||
gcsGitHash.remove(QRegExp("^[0]*"));
|
|
||||||
QString gcsGitDate = gcsDescription.mid(gcsDescription.indexOf(" ") + 1, 14);
|
|
||||||
|
|
||||||
QString gcsUavoHashStr;
|
|
||||||
QString fwUavoHashStr;
|
|
||||||
foreach(char i, fwVersion) {
|
|
||||||
fwUavoHashStr.append(QString::number(i, 16).right(2));
|
|
||||||
}
|
|
||||||
foreach(char i, uavoHashArray) {
|
|
||||||
gcsUavoHashStr.append(QString::number(i, 16).right(2));
|
|
||||||
}
|
|
||||||
QString gcsVersion = gcsGitDate + " (" + gcsGitHash + "-" + gcsUavoHashStr.left(8) + ")";
|
|
||||||
QString fwVersion = boardDescription.gitDate + " (" + boardDescription.gitHash + "-" + fwUavoHashStr.left(8) + ")";
|
|
||||||
|
|
||||||
QString warning = QString(tr(
|
|
||||||
"GCS and firmware versions of the UAV objects set do not match which can cause configuration problems. "
|
|
||||||
"GCS version: %1 Firmware version: %2.")).arg(gcsVersion).arg(fwVersion);
|
|
||||||
if (!errorMsg) {
|
|
||||||
errorMsg = new QErrorMessage(Core::ICore::instance()->mainWindow());
|
|
||||||
}
|
|
||||||
errorMsg->showMessage(warning);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include "uploader_global.h"
|
#include "uploader_global.h"
|
||||||
|
|
||||||
class UploaderGadgetFactory;
|
class UploaderGadgetFactory;
|
||||||
class QErrorMessage;
|
|
||||||
|
|
||||||
class UPLOADER_EXPORT UploaderPlugin : public ExtensionSystem::IPlugin {
|
class UPLOADER_EXPORT UploaderPlugin : public ExtensionSystem::IPlugin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -46,12 +45,8 @@ public:
|
|||||||
bool initialize(const QStringList & arguments, QString *errorString);
|
bool initialize(const QStringList & arguments, QString *errorString);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void versionMatchCheck();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UploaderGadgetFactory *mf;
|
UploaderGadgetFactory *mf;
|
||||||
QErrorMessage *errorMsg;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UPLOADERPLUGIN_H
|
#endif // UPLOADERPLUGIN_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user