mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
OP-1174 OP-1131 moved firmware version check from uploader gadget to uploader plugin.
This ensures that the check is always done even if the uploader gadget is not displayed.
This commit is contained in:
parent
4b379a1816
commit
40dcd94b5c
@ -25,12 +25,20 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include "uploadergadgetwidget.h"
|
#include "uploadergadgetwidget.h"
|
||||||
#include "version_info/version_info.h"
|
|
||||||
#include "flightstatus.h"
|
|
||||||
|
|
||||||
|
#include "flightstatus.h"
|
||||||
|
//#include "delay.h"
|
||||||
|
#include "devicewidget.h"
|
||||||
|
#include "runningdevicewidget.h"
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/connectionmanager.h>
|
||||||
#include <uavtalk/telemetrymanager.h>
|
#include <uavtalk/telemetrymanager.h>
|
||||||
|
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -125,14 +133,11 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
currentStep = IAP_STATE_READY;
|
currentStep = IAP_STATE_READY;
|
||||||
resetOnly = false;
|
resetOnly = false;
|
||||||
dfu = NULL;
|
dfu = NULL;
|
||||||
msg = new QErrorMessage(this);
|
|
||||||
|
|
||||||
// Listen to autopilot connection events
|
// Listen to autopilot connection events
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
|
TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
|
||||||
connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect()));
|
connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect()));
|
||||||
connect(telMngr, SIGNAL(connected()), this, SLOT(versionMatchCheck()));
|
|
||||||
|
|
||||||
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect()));
|
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect()));
|
||||||
|
|
||||||
connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(systemHalt()));
|
connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(systemHalt()));
|
||||||
@ -162,7 +167,6 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
// And check whether by any chance we are not already connected
|
// And check whether by any chance we are not already connected
|
||||||
if (telMngr->isConnected()) {
|
if (telMngr->isConnected()) {
|
||||||
onAutopilotConnect();
|
onAutopilotConnect();
|
||||||
versionMatchCheck();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,10 +463,9 @@ void UploaderGadgetWidget::goToBootloader(UAVObject *callerObj, bool success)
|
|||||||
|
|
||||||
void UploaderGadgetWidget::systemHalt()
|
void UploaderGadgetWidget::systemHalt()
|
||||||
{
|
{
|
||||||
FlightStatus *status = getFlightStatus();
|
|
||||||
|
|
||||||
// The board can not be halted when in armed state.
|
// The board can not be halted when in armed state.
|
||||||
// If board is armed, or arming. Show message with notice.
|
// If board is armed, or arming. Show message with notice.
|
||||||
|
FlightStatus *status = getFlightStatus();
|
||||||
if (status->getArmed() == FlightStatus::ARMED_DISARMED) {
|
if (status->getArmed() == FlightStatus::ARMED_DISARMED) {
|
||||||
goToBootloader();
|
goToBootloader();
|
||||||
} else {
|
} else {
|
||||||
@ -1024,48 +1027,6 @@ void UploaderGadgetWidget::info(QString infoString, int infoNumber)
|
|||||||
m_config->boardStatus->setText(infoString);
|
m_config->boardStatus->setText(infoString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploaderGadgetWidget::versionMatchCheck()
|
|
||||||
{
|
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
||||||
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
|
|
||||||
deviceDescriptorStruct boardDescription = utilMngr->getBoardDescriptionStruct();
|
|
||||||
QByteArray uavoHashArray;
|
|
||||||
QString uavoHash = VersionInfo::uavoHashArray();
|
|
||||||
|
|
||||||
|
|
||||||
uavoHash.chop(2);
|
|
||||||
uavoHash.remove(0, 2);
|
|
||||||
uavoHash = uavoHash.trimmed();
|
|
||||||
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);
|
|
||||||
msg->showMessage(warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UploaderGadgetWidget::openHelp()
|
void UploaderGadgetWidget::openHelp()
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl(QUrl("http://wiki.openpilot.org/x/AoBZ", QUrl::StrictMode));
|
QDesktopServices::openUrl(QUrl("http://wiki.openpilot.org/x/AoBZ", QUrl::StrictMode));
|
||||||
|
@ -29,38 +29,18 @@
|
|||||||
#define UPLOADERGADGETWIDGET_H
|
#define UPLOADERGADGETWIDGET_H
|
||||||
|
|
||||||
#include "ui_uploader.h"
|
#include "ui_uploader.h"
|
||||||
#include "delay.h"
|
|
||||||
#include "devicewidget.h"
|
|
||||||
#include "runningdevicewidget.h"
|
|
||||||
#include "op_dfu.h"
|
|
||||||
#include <QtSerialPort/QSerialPort>
|
|
||||||
#include <QtSerialPort/QSerialPortInfo>
|
|
||||||
|
|
||||||
#include "extensionsystem/pluginmanager.h"
|
|
||||||
#include "uavobjectmanager.h"
|
|
||||||
#include "uavobject.h"
|
|
||||||
|
|
||||||
#include "coreplugin/icore.h"
|
|
||||||
#include "coreplugin/connectionmanager.h"
|
|
||||||
|
|
||||||
#include "ophid/inc/ophid_plugin.h"
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QThread>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QTimer>
|
|
||||||
#include "devicedescriptorstruct.h"
|
|
||||||
#include <QProgressDialog>
|
|
||||||
#include <QErrorMessage>
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#include "uploader_global.h"
|
#include "uploader_global.h"
|
||||||
|
|
||||||
#include "enums.h"
|
#include "enums.h"
|
||||||
|
#include "op_dfu.h"
|
||||||
|
|
||||||
|
#include <QProgressDialog>
|
||||||
|
|
||||||
using namespace OP_DFU;
|
using namespace OP_DFU;
|
||||||
using namespace uploader;
|
using namespace uploader;
|
||||||
|
|
||||||
class FlightStatus;
|
class FlightStatus;
|
||||||
|
class UAVObject;
|
||||||
|
|
||||||
class TimedDialog: public QProgressDialog {
|
class TimedDialog: public QProgressDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -119,6 +99,7 @@ public:
|
|||||||
~UploaderGadgetWidget();
|
~UploaderGadgetWidget();
|
||||||
|
|
||||||
static const int BOARD_EVENT_TIMEOUT;
|
static const int BOARD_EVENT_TIMEOUT;
|
||||||
|
static const int AUTOUPDATE_CLOSE_TIMEOUT;
|
||||||
|
|
||||||
void log(QString str);
|
void log(QString str);
|
||||||
bool autoUpdateCapable();
|
bool autoUpdateCapable();
|
||||||
@ -144,15 +125,12 @@ private:
|
|||||||
void clearLog();
|
void clearLog();
|
||||||
QString getPortDevice(const QString &friendName);
|
QString getPortDevice(const QString &friendName);
|
||||||
QLineEdit *openFileNameLE;
|
QLineEdit *openFileNameLE;
|
||||||
QErrorMessage *msg;
|
|
||||||
void connectSignalSlot(QWidget *widget);
|
void connectSignalSlot(QWidget *widget);
|
||||||
FlightStatus *getFlightStatus();
|
FlightStatus *getFlightStatus();
|
||||||
void bootButtonsSetEnable(bool enabled);
|
void bootButtonsSetEnable(bool enabled);
|
||||||
static const int AUTOUPDATE_CLOSE_TIMEOUT;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onPhysicalHWConnect();
|
void onPhysicalHWConnect();
|
||||||
void versionMatchCheck();
|
|
||||||
void error(QString errorString, int errorNumber);
|
void error(QString errorString, int errorNumber);
|
||||||
void info(QString infoString, int infoNumber);
|
void info(QString infoString, int infoNumber);
|
||||||
void goToBootloader(UAVObject * = NULL, bool = false);
|
void goToBootloader(UAVObject * = NULL, bool = false);
|
||||||
|
@ -26,11 +26,21 @@
|
|||||||
*/
|
*/
|
||||||
#include "uploaderplugin.h"
|
#include "uploaderplugin.h"
|
||||||
#include "uploadergadgetfactory.h"
|
#include "uploadergadgetfactory.h"
|
||||||
#include <QtPlugin>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
|
|
||||||
UploaderPlugin::UploaderPlugin()
|
#include "version_info/version_info.h"
|
||||||
|
#include "devicedescriptorstruct.h"
|
||||||
|
#include "uavobjectutilmanager.h"
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <uavtalk/telemetrymanager.h>
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QErrorMessage>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
UploaderPlugin::UploaderPlugin() : errorMsg(0)
|
||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
@ -44,8 +54,15 @@ bool UploaderPlugin::initialize(const QStringList & args, QString *errMsg)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(args);
|
Q_UNUSED(args);
|
||||||
Q_UNUSED(errMsg);
|
Q_UNUSED(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,5 +73,52 @@ void UploaderPlugin::extensionsInitialized()
|
|||||||
|
|
||||||
void UploaderPlugin::shutdown()
|
void UploaderPlugin::shutdown()
|
||||||
{
|
{
|
||||||
// Do nothing
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
|
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 = 0;//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,6 +32,7 @@
|
|||||||
#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
|
||||||
@ -44,8 +45,13 @@ public:
|
|||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
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