From 8c6526cf25005dc3f9b474c4f37cfebd02ae0a67 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Sat, 28 May 2011 22:14:15 +0300 Subject: [PATCH 1/3] gcs: add git version info to the About dialog using version-info.py --- .../src/plugins/coreplugin/coreplugin.pro | 2 ++ .../src/plugins/coreplugin/gcsversioninfo.pri | 35 +++++++++++++++++++ .../src/plugins/coreplugin/versiondialog.cpp | 2 +- .../src/plugins/coreplugin/versiondialog.h | 3 ++ make/templates/gcsversioninfotemplate.h | 32 +++++++++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 ground/openpilotgcs/src/plugins/coreplugin/gcsversioninfo.pri create mode 100644 make/templates/gcsversioninfotemplate.h diff --git a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro index 8112438ed..70ac509e8 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro +++ b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro @@ -141,3 +141,5 @@ unix:!macx { INSTALLS += images } OTHER_FILES += Core.pluginspec + +include(gcsversioninfo.pri) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/gcsversioninfo.pri b/ground/openpilotgcs/src/plugins/coreplugin/gcsversioninfo.pri new file mode 100644 index 000000000..559dc3528 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/coreplugin/gcsversioninfo.pri @@ -0,0 +1,35 @@ +# +# This qmake file generates a header with the GCS version info string. +# +# This is a bit tricky since the script should be run always and before +# the other dependencies evaluation. +# + +# Since debug_and_release option is set, we need this +!debug_and_release|build_pass { + ROOT_DIR = $$GCS_SOURCE_TREE/../.. + VERSION_INFO_HEADER = $$GCS_BUILD_TREE/gcsversioninfo.h + VERSION_INFO_SCRIPT = $$ROOT_DIR/make/scripts/version-info.py + VERSION_INFO_TEMPLATE = $$ROOT_DIR/make/templates/gcsversioninfotemplate.h + VERSION_INFO_COMMAND = python \"$$VERSION_INFO_SCRIPT\" + + # Create custom version_info target which generates a header + version_info.target = $$VERSION_INFO_HEADER + version_info.commands = $$VERSION_INFO_COMMAND \ + --path=\"$$GCS_SOURCE_TREE\" \ + --template=\"$$VERSION_INFO_TEMPLATE\" \ + --outfile=\"$$VERSION_INFO_HEADER\" + version_info.depends = FORCE + QMAKE_EXTRA_TARGETS += version_info + + # Hook version_info target in between qmake's Makefile update and + # the actual project target + version_info_hook.depends = version_info + debug_and_release { + CONFIG(debug,debug|release):version_info_hook.target = Makefile.Debug + CONFIG(release,debug|release):version_info_hook.target = Makefile.Release + } else { + version_info_hook.target = Makefile + } + QMAKE_EXTRA_TARGETS += version_info_hook +} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.cpp b/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.cpp index cd4200765..aa8239f6e 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.cpp @@ -65,7 +65,7 @@ VersionDialog::VersionDialog(QWidget *parent) QString ideRev; #ifdef GCS_REVISION //: This gets conditionally inserted as argument %8 into the description string. - ideRev = tr("From revision %1
").arg(QString::fromLatin1(GCS_REVISION_STR).left(10)); + ideRev = tr("From revision %1
").arg(QString::fromLatin1(GCS_REVISION_STR).left(60)); #endif const QString description = tr( diff --git a/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.h b/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.h index 1293e7313..ab6ec24d2 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/versiondialog.h @@ -29,6 +29,9 @@ #ifndef VERSIONDIALOG_H #define VERSIONDIALOG_H +// autogenerated version info string +#include "../../../../../build/ground/openpilotgcs/gcsversioninfo.h" + #include namespace Core { diff --git a/make/templates/gcsversioninfotemplate.h b/make/templates/gcsversioninfotemplate.h new file mode 100644 index 000000000..2130f59bf --- /dev/null +++ b/make/templates/gcsversioninfotemplate.h @@ -0,0 +1,32 @@ +/** + ****************************************************************************** + * + * @file ${OUTFILENAME} + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011. + * @brief GCS revision info file autogenerated using template + * ${TEMPLATE} + * + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * 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 + */ + +#define GCS_REVISION ${TAG_OR_BRANCH}:${HASH8}${DIRTY} ${DATETIME} + +/** + * @} + */ From 0305dc109439f8e059af88d5600ede957efbcb1f Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Mon, 30 May 2011 02:35:14 +0300 Subject: [PATCH 2/3] package: replace 'spektrum' by 'dsm2sat' in the binary name --- package/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/Makefile b/package/Makefile index 67db6b129..1b27755e8 100644 --- a/package/Makefile +++ b/package/Makefile @@ -103,7 +103,7 @@ endef # Firmware for different input drivers $(eval $(call INSTALL_TEMPLATE,fw_common,uavobjects,$(FW_DIR),,-$(PACKAGE_LBL),,,$(FW_TARGETS_COMMON),install)) $(eval $(call INSTALL_TEMPLATE,fw_pwm,uavobjects,$(FW_DIR),,-pwm-$(PACKAGE_LBL),,clean,$(FW_TARGETS_INPUT),install)) -$(eval $(call INSTALL_TEMPLATE,fw_spektrum,uavobjects,$(FW_DIR),,-spektrum-$(PACKAGE_LBL),USE_SPEKTRUM=YES,clean,$(FW_TARGETS_INPUT),install)) +$(eval $(call INSTALL_TEMPLATE,fw_spektrum,uavobjects,$(FW_DIR),,-dsm2sat-$(PACKAGE_LBL),USE_SPEKTRUM=YES,clean,$(FW_TARGETS_INPUT),install)) $(eval $(call INSTALL_TEMPLATE,fw_ppm,uavobjects,$(FW_DIR),,-ppm-$(PACKAGE_LBL),USE_PPM=YES,clean,$(FW_TARGETS_INPUT),install)) # Bootloaders (change 'install' to 'bin' if you don't want to install bootloaders) From 144ca219a5c36a94afdc2cb518266f96dabe0af7 Mon Sep 17 00:00:00 2001 From: zedamota Date: Fri, 27 May 2011 11:49:15 +0100 Subject: [PATCH 3/3] Cosmetic changes to Uploader Gadget Rescue mode --- .../plugins/uploader/uploadergadgetwidget.cpp | 222 ++++++++++-------- .../plugins/uploader/uploadergadgetwidget.h | 10 +- 2 files changed, 128 insertions(+), 104 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp index 2943bcdfd..5a4b350b2 100755 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp @@ -33,7 +33,6 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent) m_config = new Ui_UploaderWidget(); m_config->setupUi(this); currentStep = IAP_STATE_READY; - rescueStep = RESCUE_STEP0; resetOnly=false; dfu = NULL; @@ -393,89 +392,93 @@ void UploaderGadgetWidget::systemBoot() void UploaderGadgetWidget::systemRescue() { Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager(); - switch (rescueStep) { - case RESCUE_STEP0: { - cm->disconnectDevice(); - // stop the polling thread: otherwise it will mess up DFU - cm->suspendPolling(); - // Delete all previous tabs: - while (m_config->systemElements->count()) { - QWidget *qw = m_config->systemElements->widget(0); - m_config->systemElements->removeTab(0); - delete qw; - } - // Existing DFU objects will have a handle over USB and will - // disturb everything for the rescue process: - if (dfu) { - delete dfu; - dfu = NULL; - } - // Avoid dumb users pressing Rescue twice. It can happen. - m_config->rescueButton->setEnabled(false); - - // Now we're good to go: - clearLog(); - log("**********************************************************"); - log("** Follow those instructions to attempt a system rescue **"); - log("**********************************************************"); - log("You will be prompted to first connect USB, then system power"); - log ("Connect USB in 2 seconds..."); - rescueStep = RESCUE_STEP1; - QTimer::singleShot(1000, this, SLOT(systemRescue())); + cm->disconnectDevice(); + // stop the polling thread: otherwise it will mess up DFU + cm->suspendPolling(); + // Delete all previous tabs: + while (m_config->systemElements->count()) { + QWidget *qw = m_config->systemElements->widget(0); + m_config->systemElements->removeTab(0); + delete qw; } - break; - case RESCUE_STEP1: - rescueStep = RESCUE_STEP2; - log (" ...1..."); - QTimer::singleShot(1000, this, SLOT(systemRescue())); - break; - case RESCUE_STEP2: - rescueStep = RESCUE_STEP3; - log(" ...Now!"); - QTimer::singleShot(1000, this, SLOT(systemRescue())); - break; - case RESCUE_STEP3: - log("... Detecting First Board..."); - repaint(); - dfu = new DFUObject(DFU_DEBUG, false, QString()); - dfu->AbortOperation(); - if(!dfu->enterDFU(0)) + // Existing DFU objects will have a handle over USB and will + // disturb everything for the rescue process: + if (dfu) { + delete dfu; + dfu = NULL; + } + // Avoid dumb users pressing Rescue twice. It can happen. + m_config->rescueButton->setEnabled(false); + + // Now we're good to go: + clearLog(); + log("**********************************************************"); + log("** Follow those instructions to attempt a system rescue **"); + log("**********************************************************"); + log("You will be prompted to first connect USB, then system power"); + if(USBMonitor::instance()->availableDevices(0x20a0,-1,-1,-1).length()>0) + { + if(QMessageBox::warning(this,tr("OpenPilot Uploader"),tr("Please disconnect all openpilot boards"),QMessageBox::Ok,QMessageBox::Cancel)==QMessageBox::Cancel) { - rescueStep = RESCUE_STEP0; - log("Could not enter DFU mode."); - delete dfu; - dfu = NULL; - cm->resumePolling(); m_config->rescueButton->setEnabled(true); return; } - if(!dfu->findDevices() || (dfu->numberOfDevices != 1)) - { - rescueStep = RESCUE_STEP0; - log("Could not detect a board, aborting!"); - delete dfu; - dfu = NULL; - cm->resumePolling(); - m_config->rescueButton->setEnabled(true); - return; - } - rescueStep = RESCUE_POWER1; - log("Connect Power in 2 second..."); - log("(not required on CopterControl)"); - QTimer::singleShot(1000, this, SLOT(systemRescue())); - break; - case RESCUE_POWER1: - rescueStep = RESCUE_POWER2; - log(" ...1..."); - QTimer::singleShot(1000, this, SLOT(systemRescue())); - break; - case RESCUE_POWER2: - log("... NOW!\n***\nWaiting..."); - rescueStep = RESCUE_DETECT; - QTimer::singleShot(5000, this, SLOT(systemRescue())); - break; - case RESCUE_DETECT: - rescueStep = RESCUE_STEP0; + } + // Now we're good to go: + clearLog(); + log("**********************************************************"); + log("** Follow those instructions to attempt a system rescue **"); + log("**********************************************************"); + log("You will be prompted to first connect USB, then system power"); + pd = new QProgressDialog(tr("Please connect the board (USB only!)"), tr("Cancel"), 0, 20); + QProgressBar * bar=new QProgressBar(pd); + bar->setFormat("Timeout"); + pd->setBar(bar); + pd->setMinimumDuration(0); + pd->setRange(0,20); + connect(pd, SIGNAL(canceled()), this, SLOT(cancel())); + t = new QTimer(this); + connect(t, SIGNAL(timeout()), this, SLOT(perform())); + t->start(1000); + connect(USBMonitor::instance(), SIGNAL(deviceDiscovered(USBPortInfo)),&q, SLOT(quit())); + q.exec(); + if(!t->isActive()) + { + pd->close(); + t->stop(); + QMessageBox::warning(this,tr("Openpilot Uploader"),tr("No board connection was detected!")); + m_config->rescueButton->setEnabled(true); + return; + } + pd->close(); + t->stop(); + log("... Detecting First Board..."); + repaint(); + dfu = new DFUObject(DFU_DEBUG, false, QString()); + dfu->AbortOperation(); + if(!dfu->enterDFU(0)) + { + log("Could not enter DFU mode."); + delete dfu; + dfu = NULL; + cm->resumePolling(); + m_config->rescueButton->setEnabled(true); + return; + } + if(!dfu->findDevices() || (dfu->numberOfDevices != 1)) + { + log("Could not detect a board, aborting!"); + delete dfu; + dfu = NULL; + cm->resumePolling(); + m_config->rescueButton->setEnabled(true); + return; + } + if(QMessageBox::question(this,tr("OpenPilot Uploader"),tr("If you want to search for other boards connect power now and press Yes"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) + { + log("\nWaiting..."); + QTimer::singleShot(3000, &q, SLOT(quit())); + q.exec(); log("Detecting second board..."); repaint(); if(!dfu->findDevices()) @@ -489,28 +492,42 @@ void UploaderGadgetWidget::systemRescue() m_config->rescueButton->setEnabled(true); return; } - log(QString("Found ") + QString::number(dfu->numberOfDevices) + QString(" device(s).")); - if (dfu->numberOfDevices > 5) { - log("Inconsistent number of devices, aborting!"); - delete dfu; - dfu = NULL; - cm->resumePolling(); - m_config->rescueButton->setEnabled(true); - return; - } - for(int i=0;inumberOfDevices;i++) { - deviceWidget* dw = new deviceWidget(this); - dw->setDeviceID(i); - dw->setDfu(dfu); - dw->populate(); - m_config->systemElements->addTab(dw, QString("Device") + QString::number(i)); - } - m_config->haltButton->setEnabled(false); - m_config->resetButton->setEnabled(false); - m_config->bootButton->setEnabled(true); - m_config->rescueButton->setEnabled(false); - currentStep = IAP_STATE_BOOTLOADER; // So that we can boot from the GUI afterwards. } + log(QString("Found ") + QString::number(dfu->numberOfDevices) + QString(" device(s).")); + if (dfu->numberOfDevices > 5) { + log("Inconsistent number of devices, aborting!"); + delete dfu; + dfu = NULL; + cm->resumePolling(); + m_config->rescueButton->setEnabled(true); + return; + } + for(int i=0;inumberOfDevices;i++) { + deviceWidget* dw = new deviceWidget(this); + dw->setDeviceID(i); + dw->setDfu(dfu); + dw->populate(); + m_config->systemElements->addTab(dw, QString("Device") + QString::number(i)); + } + m_config->haltButton->setEnabled(false); + m_config->resetButton->setEnabled(false); + m_config->bootButton->setEnabled(true); + m_config->rescueButton->setEnabled(false); + currentStep = IAP_STATE_BOOTLOADER; // So that we can boot from the GUI afterwards. +} +void UploaderGadgetWidget::perform() +{ + if(pd->value()==19) + { + t->stop(); + q.exit(); + } + pd->setValue(pd->value()+1); +} +void UploaderGadgetWidget::cancel() +{ + t->stop(); + q.exit(); } /** @@ -538,6 +555,11 @@ UploaderGadgetWidget::~UploaderGadgetWidget() m_config->systemElements->removeTab(0); delete qw; } + if (pd) + delete pd; + if (t) + delete t; + } diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h index 7c7bae19e..b629ad605 100755 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h @@ -53,6 +53,7 @@ #include #include +#include using namespace OP_DFU; @@ -64,7 +65,6 @@ public: UploaderGadgetWidget(QWidget *parent = 0); ~UploaderGadgetWidget(); typedef enum { IAP_STATE_READY, IAP_STATE_STEP_1, IAP_STATE_STEP_2, IAP_STEP_RESET, IAP_STATE_BOOTLOADER} IAPStep; - typedef enum { RESCUE_STEP0, RESCUE_STEP1, RESCUE_STEP2, RESCUE_STEP3, RESCUE_POWER1, RESCUE_POWER2, RESCUE_DETECT } RescueStep; void log(QString str); public slots: @@ -75,13 +75,13 @@ private: Ui_UploaderWidget *m_config; DFUObject *dfu; IAPStep currentStep; - RescueStep rescueStep; bool resetOnly; void clearLog(); QString getPortDevice(const QString &friendName); - + QProgressDialog* pd; + QTimer* t; QLineEdit* openFileNameLE; - + QEventLoop q; private slots: void error(QString errorString,int errorNumber); void info(QString infoString,int infoNumber); @@ -90,6 +90,8 @@ private slots: void systemBoot(); void systemRescue(); void getSerialPorts(); + void perform(); + void cancel(); };