From f5811e7747594440128bd9b7591d4fbaa98fa7ff Mon Sep 17 00:00:00 2001 From: m_thread Date: Tue, 10 Mar 2015 22:20:08 +0100 Subject: [PATCH 01/44] OP-1777 Adding settings to general settings panel. --- .../plugins/coreplugin/generalsettings.cpp | 10 + .../src/plugins/coreplugin/generalsettings.h | 2 + .../src/plugins/coreplugin/generalsettings.ui | 210 +++++++++++------- 3 files changed, 139 insertions(+), 83 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp index 054fefd70..530bb543e 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp @@ -49,6 +49,7 @@ GeneralSettings::GeneralSettings() : m_autoSelect(true), m_useUDPMirror(false), m_useExpertMode(false), + m_collectUsageData(true), m_dialog(0) {} @@ -125,6 +126,7 @@ QWidget *GeneralSettings::createPage(QWidget *parent) m_page->checkAutoSelect->setChecked(m_autoSelect); m_page->cbUseUDPMirror->setChecked(m_useUDPMirror); m_page->cbExpertMode->setChecked(m_useExpertMode); + m_page->cbUsageData->setChecked(m_collectUsageData); m_page->colorButton->setColor(StyleHelper::baseColor()); connect(m_page->resetButton, SIGNAL(clicked()), this, SLOT(resetInterfaceColor())); @@ -145,6 +147,7 @@ void GeneralSettings::apply() m_useExpertMode = m_page->cbExpertMode->isChecked(); m_autoConnect = m_page->checkAutoConnect->isChecked(); m_autoSelect = m_page->checkAutoSelect->isChecked(); + m_collectUsageData = m_page->cbUsageData->isChecked(); } void GeneralSettings::finish() @@ -161,6 +164,7 @@ void GeneralSettings::readSettings(QSettings *qs) m_autoSelect = qs->value(QLatin1String("AutoSelect"), m_autoSelect).toBool(); m_useUDPMirror = qs->value(QLatin1String("UDPMirror"), m_useUDPMirror).toBool(); m_useExpertMode = qs->value(QLatin1String("ExpertMode"), m_useExpertMode).toBool(); + m_collectUsageData = qs->value(QLatin1String("CollectUsageData"), m_collectUsageData).toBool(); qs->endGroup(); } @@ -179,6 +183,7 @@ void GeneralSettings::saveSettings(QSettings *qs) qs->setValue(QLatin1String("AutoSelect"), m_autoSelect); qs->setValue(QLatin1String("UDPMirror"), m_useUDPMirror); qs->setValue(QLatin1String("ExpertMode"), m_useExpertMode); + qs->setValue(QLatin1String("CollectUsageData"), m_collectUsageData); qs->endGroup(); } @@ -249,6 +254,11 @@ bool GeneralSettings::useUDPMirror() const return m_useUDPMirror; } +bool GeneralSettings::collectUsageData() const +{ + return m_collectUsageData; +} + bool GeneralSettings::useExpertMode() const { return m_useExpertMode; diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h index b03e71704..01c1c5f70 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h @@ -57,6 +57,7 @@ public: bool autoConnect() const; bool autoSelect() const; bool useUDPMirror() const; + bool collectUsageData() const; void readSettings(QSettings *qs); void saveSettings(QSettings *qs); bool useExpertMode() const; @@ -79,6 +80,7 @@ private: bool m_autoSelect; bool m_useUDPMirror; bool m_useExpertMode; + bool m_collectUsageData; QPointer m_dialog; QList m_codecs; }; diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui index 6eda799c1..2a727171f 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui @@ -11,7 +11,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -20,17 +29,73 @@ General settings - - + + - User interface color: + Language: - + + + + Expert Mode: + + + + + + + + + + + + + + false + + + + + + true + + + + + + + Automatically connect an OpenPilot USB device: + + + true + + + + + + + + + + true + + + + - + + 0 + + + 0 + + + 0 + + 0 @@ -82,46 +147,46 @@ - + + + + User interface color: + + + + + + + Gather and upload usage data: + + + + - + + 0 + + + 0 + + + 0 + + 0 - - + + - - true - - - - - Save configuration settings on exit: - - - true - - - - - - - Automatically connect an OpenPilot USB device: - - - true - - - - + @@ -131,58 +196,14 @@ - - - - Automatically select an OpenPilot USB device: - - - true - - - - - - - false - - - - - - true - - - - - - - - - - - Use UDP Mirror + Use UDP Mirror: - - - - Expert Mode - - - - - - - - - - - + @@ -202,10 +223,33 @@ - - + + - Language: + Save configuration settings on exit: + + + true + + + + + + + Automatically select an OpenPilot USB device: + + + true + + + + + + + + + + true From 867742d10256c7df1d7460fc64e8d63d76505502 Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 11 Mar 2015 01:09:19 +0100 Subject: [PATCH 02/44] OP-1777 Adding usage tracker plugin and basic functionality. --- ground/openpilotgcs/src/plugins/plugins.pro | 8 ++ .../usagetracker/usagetracker.pluginspec | 12 ++ .../src/plugins/usagetracker/usagetracker.pro | 14 +++ .../usagetracker/usagetrackerplugin.cpp | 107 ++++++++++++++++++ .../plugins/usagetracker/usagetrackerplugin.h | 53 +++++++++ 5 files changed, 194 insertions(+) create mode 100644 ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pluginspec create mode 100644 ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro create mode 100644 ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp create mode 100644 ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h diff --git a/ground/openpilotgcs/src/plugins/plugins.pro b/ground/openpilotgcs/src/plugins/plugins.pro index 2019d848d..ab2e30fbd 100644 --- a/ground/openpilotgcs/src/plugins/plugins.pro +++ b/ground/openpilotgcs/src/plugins/plugins.pro @@ -252,3 +252,11 @@ plugin_flightlog.depends += plugin_uavobjects plugin_flightlog.depends += plugin_uavtalk SUBDIRS += plugin_flightlog +# Usage Tracker plugin +plugin_usagetracker.subdir = usagetracker +plugin_usagetracker.depends = plugin_coreplugin +plugin_usagetracker.depends += plugin_uavobjects +plugin_usagetracker.depends += plugin_uavtalk +plugin_setupwizard.depends += plugin_uavobjectutil +SUBDIRS += plugin_usagetracker + diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pluginspec b/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pluginspec new file mode 100644 index 000000000..d4e1c5225 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pluginspec @@ -0,0 +1,12 @@ + + The OpenPilot Project + (C) 2015 OpenPilot Project + A plugin that tracks GCS usage + http://www.openpilot.org + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro b/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro new file mode 100644 index 000000000..1eca75047 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro @@ -0,0 +1,14 @@ + +TEMPLATE = lib +TARGET = UsageTracker + +include(../../openpilotgcsplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) +include(../../plugins/uavobjects/uavobjects.pri) +include(../../plugins/uavobjectutil/uavobjectutil.pri) +include(../../plugins/uavtalk/uavtalk.pri) + +HEADERS += usagetrackerplugin.h +SOURCES += usagetrackerplugin.cpp + +OTHER_FILES += usagetracker.pluginspec diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp new file mode 100644 index 000000000..8837bfa6d --- /dev/null +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -0,0 +1,107 @@ +/** + ****************************************************************************** + * + * @file usagetrackerplugin.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup UsageTrackerPlugin Usage Tracker Plugin + * @{ + * @brief A plugin tracking GCS usage + *****************************************************************************/ +/* + * 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 "usagetrackerplugin.h" +#include +#include +#include +#include +#include +#include +#include +#include + +UsageTrackerPlugin::UsageTrackerPlugin() : + m_telemetryManager(NULL) +{ +} + +UsageTrackerPlugin::~UsageTrackerPlugin() +{ +} + +bool UsageTrackerPlugin::initialize(const QStringList & args, QString *errMsg) +{ + Q_UNUSED(args); + Q_UNUSED(errMsg); + + return true; +} + +void UsageTrackerPlugin::extensionsInitialized() +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + m_telemetryManager = pm->getObject(); + connect(m_telemetryManager, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); +} + +void UsageTrackerPlugin::shutdown() +{ + if (m_telemetryManager != NULL) { + disconnect(m_telemetryManager, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); + } +} + +void UsageTrackerPlugin::onAutopilotConnect() +{ + QTimer::singleShot(1000, this, SLOT(trackUsage())); +} + +void UsageTrackerPlugin::trackUsage() +{ + QNetworkAccessManager *networkAccessManager = new QNetworkAccessManager(); + + // This will delete the network access manager instance when we're done + connect(networkAccessManager, SIGNAL(finished(QNetworkReply *)), networkAccessManager, SLOT(deleteLater())); + + QMap parameters; + collectUsageParameters(parameters); + + QUrlQuery query; + QMapIterator iter(parameters); + while (iter.hasNext()) { + iter.next(); + query.addQueryItem(iter.key(), iter.value()); + } + QUrl url("https://www.openpilot.org/opver?" + query.toString()); + qDebug() << "Sending usage tracking as:" << url.toString(); + networkAccessManager->get(QNetworkRequest(url)); +} + +void UsageTrackerPlugin::collectUsageParameters(QMap ¶meters) +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectUtilManager *utilMngr = pm->getObject(); + + QByteArray description = utilMngr->getBoardDescription(); + deviceDescriptorStruct devDesc; + if (UAVObjectUtilManager::descriptionToStructure(description, devDesc)) { + parameters["bt"] = QString("0x%1").arg(QString::number(utilMngr->getBoardModel(),16).toUpper()); + parameters["bid"] = utilMngr->getBoardCPUSerial().toHex(); + parameters["bfwt"] = devDesc.gitTag; + parameters["bfwh"] = devDesc.gitHash; + } +} diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h new file mode 100644 index 000000000..daa33a37c --- /dev/null +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h @@ -0,0 +1,53 @@ +/** + ****************************************************************************** + * + * @file usagetrackerplugin.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup UsageTrackerPlugin Usage Tracker Plugin + * @{ + * @brief A plugin tracking GCS usage + *****************************************************************************/ +/* + * 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 USAGETRACKERPLUGIN_H +#define USAGETRACKERPLUGIN_H + +#include +#include + +class UsageTrackerPlugin : public ExtensionSystem::IPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "OpenPilot.UsageTracker") +public: + UsageTrackerPlugin(); + ~UsageTrackerPlugin(); + + void extensionsInitialized(); + bool initialize(const QStringList & arguments, QString *errorString); + void shutdown(); + +private slots: + void onAutopilotConnect(); + void trackUsage(); + void collectUsageParameters(QMap ¶meters); + +private: + TelemetryManager * m_telemetryManager; +}; + +#endif // USAGETRACKERPLUGIN_H From 3653457b28b785e182f7059fdfcfe683ce46411c Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 11 Mar 2015 10:19:28 +0100 Subject: [PATCH 03/44] OP-1777 Adding some more info and checking if we should send any usage data at all. --- .../usagetracker/usagetrackerplugin.cpp | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index 8837bfa6d..9e45dbfdb 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include "version_info/version_info.h" UsageTrackerPlugin::UsageTrackerPlugin() : m_telemetryManager(NULL) @@ -67,7 +69,11 @@ void UsageTrackerPlugin::shutdown() void UsageTrackerPlugin::onAutopilotConnect() { - QTimer::singleShot(1000, this, SLOT(trackUsage())); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + Core::Internal::GeneralSettings *settings = pm->getObject(); + if (settings->collectUsageData()) { + QTimer::singleShot(1000, this, SLOT(trackUsage())); + } } void UsageTrackerPlugin::trackUsage() @@ -84,11 +90,11 @@ void UsageTrackerPlugin::trackUsage() QMapIterator iter(parameters); while (iter.hasNext()) { iter.next(); - query.addQueryItem(iter.key(), iter.value()); + query.addQueryItem(iter.key(), QUrl::toPercentEncoding(iter.value())); } - QUrl url("https://www.openpilot.org/opver?" + query.toString()); - qDebug() << "Sending usage tracking as:" << url.toString(); - networkAccessManager->get(QNetworkRequest(url)); + QUrl url("https://www.openpilot.org/opver?" + query.toString(QUrl::FullyEncoded)); + qDebug() << "Sending usage tracking as:" << url.toEncoded(QUrl::FullyEncoded); + networkAccessManager->get(QNetworkRequest(QUrl(url.toEncoded(QUrl::FullyEncoded)))); } void UsageTrackerPlugin::collectUsageParameters(QMap ¶meters) @@ -99,9 +105,13 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete QByteArray description = utilMngr->getBoardDescription(); deviceDescriptorStruct devDesc; if (UAVObjectUtilManager::descriptionToStructure(description, devDesc)) { - parameters["bt"] = QString("0x%1").arg(QString::number(utilMngr->getBoardModel(),16).toUpper()); - parameters["bid"] = utilMngr->getBoardCPUSerial().toHex(); - parameters["bfwt"] = devDesc.gitTag; - parameters["bfwh"] = devDesc.gitHash; + parameters["hi0"] = "0x" + QString::number(utilMngr->getBoardModel(), 16).toLower(); + parameters["hi1"] = utilMngr->getBoardCPUSerial().toHex(); + parameters["bi0"] = QString::number(utilMngr->getBootloaderRevision()); + parameters["fi0"] = devDesc.gitTag; + parameters["fi1"] = devDesc.gitHash; + parameters["oi0"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); + parameters["si0"] = VersionInfo::revision(); + parameters["ti0"] = QDateTime::currentDateTime().toString(Qt::ISODate); } } From 4d780b0ffd79d9dc7db8b49c6f5a99c39143fd78 Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 11 Mar 2015 13:36:28 +0100 Subject: [PATCH 04/44] OP-1777 Adding disclaimer dialog and setting to hide it. --- .../plugins/coreplugin/generalsettings.cpp | 23 ++++++++++- .../src/plugins/coreplugin/generalsettings.h | 5 ++- .../usagetracker/usagetrackerplugin.cpp | 41 +++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp index 530bb543e..409dc47d2 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp @@ -50,6 +50,7 @@ GeneralSettings::GeneralSettings() : m_useUDPMirror(false), m_useExpertMode(false), m_collectUsageData(true), + m_showUsageDataDisclaimer(true), m_dialog(0) {} @@ -147,7 +148,7 @@ void GeneralSettings::apply() m_useExpertMode = m_page->cbExpertMode->isChecked(); m_autoConnect = m_page->checkAutoConnect->isChecked(); m_autoSelect = m_page->checkAutoSelect->isChecked(); - m_collectUsageData = m_page->cbUsageData->isChecked(); + setCollectUsageData(m_page->cbUsageData->isChecked()); } void GeneralSettings::finish() @@ -165,6 +166,7 @@ void GeneralSettings::readSettings(QSettings *qs) m_useUDPMirror = qs->value(QLatin1String("UDPMirror"), m_useUDPMirror).toBool(); m_useExpertMode = qs->value(QLatin1String("ExpertMode"), m_useExpertMode).toBool(); m_collectUsageData = qs->value(QLatin1String("CollectUsageData"), m_collectUsageData).toBool(); + m_showUsageDataDisclaimer = qs->value(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer).toBool(); qs->endGroup(); } @@ -184,6 +186,7 @@ void GeneralSettings::saveSettings(QSettings *qs) qs->setValue(QLatin1String("UDPMirror"), m_useUDPMirror); qs->setValue(QLatin1String("ExpertMode"), m_useExpertMode); qs->setValue(QLatin1String("CollectUsageData"), m_collectUsageData); + qs->setValue(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer); qs->endGroup(); } @@ -259,11 +262,29 @@ bool GeneralSettings::collectUsageData() const return m_collectUsageData; } +bool GeneralSettings::showUsageDataDisclaimer() const +{ + return m_showUsageDataDisclaimer; +} + bool GeneralSettings::useExpertMode() const { return m_useExpertMode; } +bool GeneralSettings::setCollectUsageData(bool collect) +{ + if (collect && collect != m_collectUsageData) { + setShowUsageDataDisclaimer(true); + } + m_collectUsageData = collect; +} + +bool GeneralSettings::setShowUsageDataDisclaimer(bool show) +{ + m_showUsageDataDisclaimer = show; +} + void GeneralSettings::slotAutoConnect(int value) { if (value == Qt::Checked) { diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h index 01c1c5f70..24a6acf14 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h @@ -58,10 +58,12 @@ public: bool autoSelect() const; bool useUDPMirror() const; bool collectUsageData() const; + bool showUsageDataDisclaimer() const; void readSettings(QSettings *qs); void saveSettings(QSettings *qs); bool useExpertMode() const; -signals: + bool setCollectUsageData(bool collect); + bool setShowUsageDataDisclaimer(bool show); private slots: void resetInterfaceColor(); @@ -81,6 +83,7 @@ private: bool m_useUDPMirror; bool m_useExpertMode; bool m_collectUsageData; + bool m_showUsageDataDisclaimer; QPointer m_dialog; QList m_codecs; }; diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index 9e45dbfdb..5fd2eb8c0 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -30,11 +30,15 @@ #include #include #include +#include #include +#include #include #include #include #include "version_info/version_info.h" +#include "coreplugin/icore.h" +#include "qmainwindow.h" UsageTrackerPlugin::UsageTrackerPlugin() : m_telemetryManager(NULL) @@ -72,6 +76,43 @@ void UsageTrackerPlugin::onAutopilotConnect() ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); Core::Internal::GeneralSettings *settings = pm->getObject(); if (settings->collectUsageData()) { + if (settings->showUsageDataDisclaimer()) { + QMessageBox message; + message.setWindowTitle(tr("Usage data collection")); + message.setIcon(QMessageBox::Information); + message.addButton(tr("Yes allow collecting information"), QMessageBox::AcceptRole); + message.addButton(tr("No do not allow collecting information"), QMessageBox::RejectRole); + message.setText(tr("Openpilot GCS has a function to collect limited anonymous information about " + "the usage of the application itself and the OpenPilot hardware connected to it.\n\n" + "The intention is to not include anything that can be considered sensitive " + "or a threat to the users integrity. The collected information will be sent " + "using a secure protocol to an OpenPilot web service and stored in a database " + "for later analysis and statistical purposes.\n" + "No information will be sold or given to any third party. The sole purpose is " + "to collect statistics about the usage of our software and hardware to enable us " + "to make things better for you users.\n\n" + "The following things are collected:\n" + "- Bootloader version\n" + "- Firmware version, tag and git hash\n" + "- OP Hardware type, revision and mcu serial number\n" + "- GCS version\n" + "- Operating system version and architecture\n" + "- Current local time\n\n" + "It is possible to enable or disable this functionality in the general " + "settings part of the options for the GCS application at any time.\n\n" + "Thank You for helping us making things better and for supporting OpenPilot!")); + QCheckBox* disclaimerCb = new QCheckBox(tr("&Don't show this message again.")); + disclaimerCb->setChecked(true); + message.setCheckBox(disclaimerCb); + if (message.exec() != QMessageBox::AcceptRole) { + settings->setCollectUsageData(false); + settings->setShowUsageDataDisclaimer(!message.checkBox()->isChecked()); + return; + } else { + settings->setCollectUsageData(true); + settings->setShowUsageDataDisclaimer(!message.checkBox()->isChecked()); + } + } QTimer::singleShot(1000, this, SLOT(trackUsage())); } } From c186a55243196af0fc435d0b4e508443096591d7 Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 11 Mar 2015 13:53:59 +0100 Subject: [PATCH 05/44] OP-1777 Updated some text. --- .../src/plugins/usagetracker/usagetrackerplugin.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index 5fd2eb8c0..4eec6b90e 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -78,10 +78,10 @@ void UsageTrackerPlugin::onAutopilotConnect() if (settings->collectUsageData()) { if (settings->showUsageDataDisclaimer()) { QMessageBox message; - message.setWindowTitle(tr("Usage data collection")); + message.setWindowTitle(tr("Usage feedback")); message.setIcon(QMessageBox::Information); - message.addButton(tr("Yes allow collecting information"), QMessageBox::AcceptRole); - message.addButton(tr("No do not allow collecting information"), QMessageBox::RejectRole); + message.addButton(tr("Yes, count me in"), QMessageBox::AcceptRole); + message.addButton(tr("No, I will not help"), QMessageBox::RejectRole); message.setText(tr("Openpilot GCS has a function to collect limited anonymous information about " "the usage of the application itself and the OpenPilot hardware connected to it.\n\n" "The intention is to not include anything that can be considered sensitive " @@ -90,16 +90,19 @@ void UsageTrackerPlugin::onAutopilotConnect() "for later analysis and statistical purposes.\n" "No information will be sold or given to any third party. The sole purpose is " "to collect statistics about the usage of our software and hardware to enable us " - "to make things better for you users.\n\n" + "to make things better for you.\n\n" "The following things are collected:\n" "- Bootloader version\n" "- Firmware version, tag and git hash\n" "- OP Hardware type, revision and mcu serial number\n" "- GCS version\n" "- Operating system version and architecture\n" - "- Current local time\n\n" + "- Current local time\n" + "The information is collected only at the time when a board is connecting to GCS.\n\n" "It is possible to enable or disable this functionality in the general " "settings part of the options for the GCS application at any time.\n\n" + "We need your help, with your feedback we know where to improve things and what " + "platforms are in use. This is a community project that depends on people being involved.\n" "Thank You for helping us making things better and for supporting OpenPilot!")); QCheckBox* disclaimerCb = new QCheckBox(tr("&Don't show this message again.")); disclaimerCb->setChecked(true); From a3f9d421461d2c4c1199a52a5f7cdfe358c5ad55 Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 11 Mar 2015 14:14:54 +0100 Subject: [PATCH 06/44] OP-1777 Adding some text to disclaimer --- .../src/plugins/usagetracker/usagetrackerplugin.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index 4eec6b90e..0dd39d639 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -95,6 +95,7 @@ void UsageTrackerPlugin::onAutopilotConnect() "- Bootloader version\n" "- Firmware version, tag and git hash\n" "- OP Hardware type, revision and mcu serial number\n" + "- Selected configuration parameters\n" "- GCS version\n" "- Operating system version and architecture\n" "- Current local time\n" @@ -157,5 +158,8 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete parameters["oi0"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); parameters["si0"] = VersionInfo::revision(); parameters["ti0"] = QDateTime::currentDateTime().toString(Qt::ISODate); + + // Configuration parameters + //parameters["ci0"] = ; } } From 779a1823e2acefb70fa3d9fb6e0d86250a850a32 Mon Sep 17 00:00:00 2001 From: m_thread Date: Wed, 11 Mar 2015 21:03:32 +0100 Subject: [PATCH 07/44] OP-1777 Changed some encoding. Changed parameter names to be meaningful. --- .../usagetracker/usagetrackerplugin.cpp | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index 0dd39d639..c890d9379 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -33,12 +33,14 @@ #include #include #include +#include #include #include #include #include "version_info/version_info.h" #include "coreplugin/icore.h" #include "qmainwindow.h" +#include "manualcontrolsettings.h" UsageTrackerPlugin::UsageTrackerPlugin() : m_telemetryManager(NULL) @@ -135,8 +137,10 @@ void UsageTrackerPlugin::trackUsage() QMapIterator iter(parameters); while (iter.hasNext()) { iter.next(); - query.addQueryItem(iter.key(), QUrl::toPercentEncoding(iter.value())); + query.addQueryItem(iter.key(), iter.value()); } + qDebug() << "Parameters unencoded:" << query.toString(); + qDebug() << "Parameters encoded:" << query.toString(QUrl::FullyEncoded); QUrl url("https://www.openpilot.org/opver?" + query.toString(QUrl::FullyEncoded)); qDebug() << "Sending usage tracking as:" << url.toEncoded(QUrl::FullyEncoded); networkAccessManager->get(QNetworkRequest(QUrl(url.toEncoded(QUrl::FullyEncoded)))); @@ -150,16 +154,19 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete QByteArray description = utilMngr->getBoardDescription(); deviceDescriptorStruct devDesc; if (UAVObjectUtilManager::descriptionToStructure(description, devDesc)) { - parameters["hi0"] = "0x" + QString::number(utilMngr->getBoardModel(), 16).toLower(); - parameters["hi1"] = utilMngr->getBoardCPUSerial().toHex(); - parameters["bi0"] = QString::number(utilMngr->getBootloaderRevision()); - parameters["fi0"] = devDesc.gitTag; - parameters["fi1"] = devDesc.gitHash; - parameters["oi0"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); - parameters["si0"] = VersionInfo::revision(); - parameters["ti0"] = QDateTime::currentDateTime().toString(Qt::ISODate); + parameters["board_type"] = "0x" + QString::number(utilMngr->getBoardModel(), 16).toLower(); + parameters["board_serial"] = utilMngr->getBoardCPUSerial().toHex(); + parameters["bl_version"] = QString::number(utilMngr->getBootloaderRevision()); + parameters["fw_tag"] = devDesc.gitTag; + parameters["fw_hash"] = devDesc.gitHash; + parameters["os_version"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); + parameters["gcs_version"] = VersionInfo::revision(); + parameters["localtime"] = QDateTime::currentDateTime().toString(Qt::ISODate); // Configuration parameters - //parameters["ci0"] = ; + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objManager = pm->getObject(); + ManualControlSettings * controlSettings = ManualControlSettings::GetInstance(objManager); + parameters["conf_receiver"] = controlSettings->getField("ChannelGroups")->getValue(ManualControlSettings::CHANNELGROUPS_THROTTLE).toString(); } } From daad175c52712f7b119177c7a7078325052a4215 Mon Sep 17 00:00:00 2001 From: m_thread Date: Fri, 13 Mar 2015 00:15:33 +0100 Subject: [PATCH 08/44] OP-1777 Added some board specific settings information. --- .../plugins/coreplugin/generalsettings.cpp | 12 +-- .../usagetracker/usagetrackerplugin.cpp | 79 +++++++++++-------- .../plugins/usagetracker/usagetrackerplugin.h | 4 +- 3 files changed, 52 insertions(+), 43 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp index 409dc47d2..4d5f8d880 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp @@ -159,13 +159,13 @@ void GeneralSettings::finish() void GeneralSettings::readSettings(QSettings *qs) { qs->beginGroup(QLatin1String("General")); - m_language = qs->value(QLatin1String("OverrideLanguage"), QLocale::system().name()).toString(); + m_language = qs->value(QLatin1String("OverrideLanguage"), QLocale::system().name()).toString(); m_saveSettingsOnExit = qs->value(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit).toBool(); - m_autoConnect = qs->value(QLatin1String("AutoConnect"), m_autoConnect).toBool(); - m_autoSelect = qs->value(QLatin1String("AutoSelect"), m_autoSelect).toBool(); - m_useUDPMirror = qs->value(QLatin1String("UDPMirror"), m_useUDPMirror).toBool(); - m_useExpertMode = qs->value(QLatin1String("ExpertMode"), m_useExpertMode).toBool(); - m_collectUsageData = qs->value(QLatin1String("CollectUsageData"), m_collectUsageData).toBool(); + m_autoConnect = qs->value(QLatin1String("AutoConnect"), m_autoConnect).toBool(); + m_autoSelect = qs->value(QLatin1String("AutoSelect"), m_autoSelect).toBool(); + m_useUDPMirror = qs->value(QLatin1String("UDPMirror"), m_useUDPMirror).toBool(); + m_useExpertMode = qs->value(QLatin1String("ExpertMode"), m_useExpertMode).toBool(); + m_collectUsageData = qs->value(QLatin1String("CollectUsageData"), m_collectUsageData).toBool(); m_showUsageDataDisclaimer = qs->value(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer).toBool(); qs->endGroup(); } diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index c890d9379..10a442bf2 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -44,12 +45,10 @@ UsageTrackerPlugin::UsageTrackerPlugin() : m_telemetryManager(NULL) -{ -} +{} UsageTrackerPlugin::~UsageTrackerPlugin() -{ -} +{} bool UsageTrackerPlugin::initialize(const QStringList & args, QString *errMsg) { @@ -62,6 +61,7 @@ bool UsageTrackerPlugin::initialize(const QStringList & args, QString *errMsg) void UsageTrackerPlugin::extensionsInitialized() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + m_telemetryManager = pm->getObject(); connect(m_telemetryManager, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); } @@ -77,6 +77,7 @@ void UsageTrackerPlugin::onAutopilotConnect() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); Core::Internal::GeneralSettings *settings = pm->getObject(); + if (settings->collectUsageData()) { if (settings->showUsageDataDisclaimer()) { QMessageBox message; @@ -85,29 +86,29 @@ void UsageTrackerPlugin::onAutopilotConnect() message.addButton(tr("Yes, count me in"), QMessageBox::AcceptRole); message.addButton(tr("No, I will not help"), QMessageBox::RejectRole); message.setText(tr("Openpilot GCS has a function to collect limited anonymous information about " - "the usage of the application itself and the OpenPilot hardware connected to it.\n\n" - "The intention is to not include anything that can be considered sensitive " - "or a threat to the users integrity. The collected information will be sent " - "using a secure protocol to an OpenPilot web service and stored in a database " - "for later analysis and statistical purposes.\n" - "No information will be sold or given to any third party. The sole purpose is " - "to collect statistics about the usage of our software and hardware to enable us " - "to make things better for you.\n\n" - "The following things are collected:\n" - "- Bootloader version\n" - "- Firmware version, tag and git hash\n" - "- OP Hardware type, revision and mcu serial number\n" - "- Selected configuration parameters\n" - "- GCS version\n" - "- Operating system version and architecture\n" - "- Current local time\n" - "The information is collected only at the time when a board is connecting to GCS.\n\n" - "It is possible to enable or disable this functionality in the general " - "settings part of the options for the GCS application at any time.\n\n" - "We need your help, with your feedback we know where to improve things and what " - "platforms are in use. This is a community project that depends on people being involved.\n" - "Thank You for helping us making things better and for supporting OpenPilot!")); - QCheckBox* disclaimerCb = new QCheckBox(tr("&Don't show this message again.")); + "the usage of the application itself and the OpenPilot hardware connected to it.\n\n" + "The intention is to not include anything that can be considered sensitive " + "or a threat to the users integrity. The collected information will be sent " + "using a secure protocol to an OpenPilot web service and stored in a database " + "for later analysis and statistical purposes.\n" + "No information will be sold or given to any third party. The sole purpose is " + "to collect statistics about the usage of our software and hardware to enable us " + "to make things better for you.\n\n" + "The following things are collected:\n" + "- Bootloader version\n" + "- Firmware version, tag and git hash\n" + "- OP Hardware type, revision and mcu serial number\n" + "- Selected configuration parameters\n" + "- GCS version\n" + "- Operating system version and architecture\n" + "- Current local time\n" + "The information is collected only at the time when a board is connecting to GCS.\n\n" + "It is possible to enable or disable this functionality in the general " + "settings part of the options for the GCS application at any time.\n\n" + "We need your help, with your feedback we know where to improve things and what " + "platforms are in use. This is a community project that depends on people being involved.\n" + "Thank You for helping us making things better and for supporting OpenPilot!")); + QCheckBox *disclaimerCb = new QCheckBox(tr("&Don't show this message again.")); disclaimerCb->setChecked(true); message.setCheckBox(disclaimerCb); if (message.exec() != QMessageBox::AcceptRole) { @@ -153,20 +154,28 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete QByteArray description = utilMngr->getBoardDescription(); deviceDescriptorStruct devDesc; + if (UAVObjectUtilManager::descriptionToStructure(description, devDesc)) { - parameters["board_type"] = "0x" + QString::number(utilMngr->getBoardModel(), 16).toLower(); + int boardModel = utilMngr->getBoardModel(); + parameters["board_type"] = "0x" + QString::number(boardModel, 16).toLower(); parameters["board_serial"] = utilMngr->getBoardCPUSerial().toHex(); - parameters["bl_version"] = QString::number(utilMngr->getBootloaderRevision()); + parameters["bl_version"] = QString::number(utilMngr->getBootloaderRevision()); parameters["fw_tag"] = devDesc.gitTag; parameters["fw_hash"] = devDesc.gitHash; - parameters["os_version"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); - parameters["gcs_version"] = VersionInfo::revision(); - parameters["localtime"] = QDateTime::currentDateTime().toString(Qt::ISODate); + parameters["os_version"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); + parameters["gcs_version"] = VersionInfo::revision(); + parameters["localtime"] = QDateTime::currentDateTime().toString(Qt::ISODate); // Configuration parameters - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject(); - ManualControlSettings * controlSettings = ManualControlSettings::GetInstance(objManager); - parameters["conf_receiver"] = controlSettings->getField("ChannelGroups")->getValue(ManualControlSettings::CHANNELGROUPS_THROTTLE).toString(); + ManualControlSettings *controlSettings = ManualControlSettings::GetInstance(objManager); + parameters["settings_receiver"] = controlSettings->getField("ChannelGroups")->getValue(ManualControlSettings::CHANNELGROUPS_THROTTLE).toString(); + + RevoSettings revoSettings = RevoSettings::GetInstance(objManager); + // Only get this info if uavo is known by controller + if (revoSettings.isKnown()) { + parameters["settings_fusion"] = revoSettings.getField("FusionAlgorithm")->getValue().toString(); + } } } diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h index daa33a37c..b06f1a325 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h @@ -32,7 +32,7 @@ class UsageTrackerPlugin : public ExtensionSystem::IPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "OpenPilot.UsageTracker") + Q_PLUGIN_METADATA(IID "OpenPilot.UsageTracker") public: UsageTrackerPlugin(); ~UsageTrackerPlugin(); @@ -47,7 +47,7 @@ private slots: void collectUsageParameters(QMap ¶meters); private: - TelemetryManager * m_telemetryManager; + TelemetryManager *m_telemetryManager; }; #endif // USAGETRACKERPLUGIN_H From 0a87b305729fa42c284d99625192ae599cdb334b Mon Sep 17 00:00:00 2001 From: m_thread Date: Fri, 13 Mar 2015 07:21:27 +0100 Subject: [PATCH 09/44] OP-1777 Fixed a compiler error. --- .../src/plugins/usagetracker/usagetrackerplugin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index 10a442bf2..23a65b1b3 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -172,10 +172,10 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete ManualControlSettings *controlSettings = ManualControlSettings::GetInstance(objManager); parameters["settings_receiver"] = controlSettings->getField("ChannelGroups")->getValue(ManualControlSettings::CHANNELGROUPS_THROTTLE).toString(); - RevoSettings revoSettings = RevoSettings::GetInstance(objManager); + RevoSettings *revoSettings = RevoSettings::GetInstance(objManager); // Only get this info if uavo is known by controller - if (revoSettings.isKnown()) { - parameters["settings_fusion"] = revoSettings.getField("FusionAlgorithm")->getValue().toString(); + if (revoSettings->isKnown()) { + parameters["settings_fusion"] = revoSettings->getField("FusionAlgorithm")->getValue().toString(); } } } From 6bb732fb02b0070ff965373014bffe77c237230a Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Sat, 14 Mar 2015 23:58:18 +0000 Subject: [PATCH 10/44] OP-1289 Need Revo to send two telemetry streams for OSD and GCS --- flight/modules/Telemetry/telemetry.c | 495 +++++++++++------- .../boards/revolution/firmware/pios_board.c | 5 +- 2 files changed, 320 insertions(+), 180 deletions(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index 142c0a2ad..c5c2350e7 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -30,6 +30,30 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* Telemetry uses four tasks. Two are created for the main telemetry + * stream called "TelTx" and "TelRx". Two are created to handle the OPLink + * radio connection, called "RadioTx" and "Radio Rx", the latter being + * overridden by USB if connected. + * + * The telemetry port to use is defined by PIOS_COM_TELEM_RF in + * PIOS_Board_Init(). + * + * A UAVTalk connection instance, telemUavTalkCon, is associated with the main + * telemetry channel and another, radioUavTalkCon, with the radio channel. + * Associated with each instance is a transmit routine which will send data + * to the appropriate port. + * + * Data is passed on the telemetry channels using queues. If + * PIOS_TELEM_PRIORITY_QUEUE is defined then two queues are created, one normal + * priority and the other high priority. + * + * The "Tx" tasks read events first from the priority queue and then from + * the normal queue, passing each event to processObjEvent() which ultimately + * passes each event to the UAVTalk library which results in the appropriate + * transmit routine being called to send the data back to the recipient on + * the telemetry or radio link. + */ + #include #include "telemetry.h" @@ -53,62 +77,72 @@ #ifdef PIOS_TELEM_RADIO_RX_STACK_SIZE #define STACK_SIZE_RADIO_RX_BYTES PIOS_TELEM_RADIO_RX_STACK_SIZE +#define STACK_SIZE_RADIO_TX_BYTES PIOS_TELEM_RADIO_TX_STACK_SIZE #else #define STACK_SIZE_RADIO_RX_BYTES STACK_SIZE_RX_BYTES +#define STACK_SIZE_RADIO_TX_BYTES STACK_SIZE_TX_BYTES #endif #define TASK_PRIORITY_RX (tskIDLE_PRIORITY + 2) #define TASK_PRIORITY_TX (tskIDLE_PRIORITY + 2) #define TASK_PRIORITY_RADRX (tskIDLE_PRIORITY + 2) +#define TASK_PRIORITY_RADTX (tskIDLE_PRIORITY + 2) #define REQ_TIMEOUT_MS 250 #define MAX_RETRIES 2 #define STATS_UPDATE_PERIOD_MS 4000 #define CONNECTION_TIMEOUT_MS 8000 // Private types +typedef struct { + // Port on which to communicate telemetry information + uint32_t telemetryPort; + // Main telemetry queue + xQueueHandle mainQueue; + #ifdef PIOS_TELEM_PRIORITY_QUEUE + // Priority telemetry queue + xQueueHandle priorityQueue; + #endif /* PIOS_TELEM_PRIORITY_QUEUE */ + // Transmit/receive task handles + xTaskHandle telemetryTxTaskHandle; + xTaskHandle telemetryRxTaskHandle; + // Telemetry stream + UAVTalkConnection uavTalkCon; +} telemetryContext; -// Private variables -static uint32_t telemetryPort; -#ifdef PIOS_INCLUDE_RFM22B -static uint32_t radioPort; -#endif -static xQueueHandle queue; +// Main telemetry port +static telemetryContext telemHandle; +static int32_t transmitData(uint8_t *data, int32_t length); +static void registerTelemObject(UAVObjHandle obj); -#if defined(PIOS_TELEM_PRIORITY_QUEUE) -static xQueueHandle priorityQueue; -#else -#define priorityQueue queue -#endif +// OPLink telemetry port +static telemetryContext radioHandle; +static int32_t transmitRadioData(uint8_t *data, int32_t length); +static void registerRadioObject(UAVObjHandle obj); -static xTaskHandle telemetryTxTaskHandle; -static xTaskHandle telemetryRxTaskHandle; -#ifdef PIOS_INCLUDE_RFM22B -static xTaskHandle radioRxTaskHandle; -#endif +// Telemetry stats static uint32_t txErrors; static uint32_t txRetries; static uint32_t timeOfLastObjectUpdate; -static UAVTalkConnection uavTalkCon; -#ifdef PIOS_INCLUDE_RFM22B -static UAVTalkConnection radioUavTalkCon; -#endif -// Private functions static void telemetryTxTask(void *parameters); static void telemetryRxTask(void *parameters); -#ifdef PIOS_INCLUDE_RFM22B -static void radioRxTask(void *parameters); -static int32_t transmitRadioData(uint8_t *data, int32_t length); -#endif -static int32_t transmitData(uint8_t *data, int32_t length); -static void registerObject(UAVObjHandle obj); -static void updateObject(UAVObjHandle obj, int32_t eventType); -static int32_t setUpdatePeriod(UAVObjHandle obj, int32_t updatePeriodMs); -static int32_t setLoggingPeriod(UAVObjHandle obj, int32_t updatePeriodMs); -static void processObjEvent(UAVObjEvent *ev); +static void updateObject( + telemetryContext *telemetryHandle, + UAVObjHandle obj, + int32_t eventType); +static void processObjEvent( + telemetryContext *telemetryHandle, + UAVObjEvent *ev); +static int32_t setUpdatePeriod( + telemetryContext *telemetryHandle, + UAVObjHandle obj, + int32_t updatePeriodMs); +static int32_t setLoggingPeriod( + telemetryContext *telemetryHandle, + UAVObjHandle obj, + int32_t updatePeriodMs); static void updateTelemetryStats(); static void gcsTelemetryStatsUpdated(); static void updateSettings(); -static uint32_t getComPort(bool input); /** * Initialise the telemetry module @@ -117,22 +151,52 @@ static uint32_t getComPort(bool input); */ int32_t TelemetryStart(void) { - // Process all registered objects and connect queue for updates - UAVObjIterate(®isterObject); + UAVObjIterate(®isterTelemObject); + UAVObjIterate(®isterRadioObject); // Listen to objects of interest - GCSTelemetryStatsConnectQueue(priorityQueue); +#ifdef PIOS_TELEM_PRIORITY_QUEUE + GCSTelemetryStatsConnectQueue(telemHandle.priorityQueue); + GCSTelemetryStatsConnectQueue(radioHandle.priorityQueue); +#else /* PIOS_TELEM_PRIORITY_QUEUE */ + GCSTelemetryStatsConnectQueue(telemHandle.mainQueue); + GCSTelemetryStatsConnectQueue(radioHandle.mainQueue); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ // Start telemetry tasks - xTaskCreate(telemetryTxTask, "TelTx", STACK_SIZE_TX_BYTES / 4, NULL, TASK_PRIORITY_TX, &telemetryTxTaskHandle); - PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, telemetryTxTaskHandle); - xTaskCreate(telemetryRxTask, "TelRx", STACK_SIZE_RX_BYTES / 4, NULL, TASK_PRIORITY_RX, &telemetryRxTaskHandle); - PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX, telemetryRxTaskHandle); + xTaskCreate(telemetryTxTask, + "TelTx", + STACK_SIZE_TX_BYTES / 4, + &telemHandle, + TASK_PRIORITY_TX, + &telemHandle.telemetryTxTaskHandle); + PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, + telemHandle.telemetryTxTaskHandle); + xTaskCreate(telemetryRxTask, + "TelRx", + STACK_SIZE_RX_BYTES / 4, + &telemHandle, + TASK_PRIORITY_RX, + &telemHandle.telemetryRxTaskHandle); + PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX, + telemHandle.telemetryRxTaskHandle); -#ifdef PIOS_INCLUDE_RFM22B - xTaskCreate(radioRxTask, "RadioRx", STACK_SIZE_RADIO_RX_BYTES / 4, NULL, TASK_PRIORITY_RADRX, &radioRxTaskHandle); - PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_RADIORX, radioRxTaskHandle); -#endif + xTaskCreate(telemetryTxTask, + "RadioTx", + STACK_SIZE_RADIO_TX_BYTES / 4, + &radioHandle, + TASK_PRIORITY_RADTX, + &radioHandle.telemetryTxTaskHandle); + PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, + radioHandle.telemetryTxTaskHandle); + xTaskCreate(telemetryRxTask, + "RadioRx", + STACK_SIZE_RADIO_RX_BYTES / 4, + &radioHandle, + TASK_PRIORITY_RADRX, + &radioHandle.telemetryRxTaskHandle); + PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_RADIORX, + radioHandle.telemetryRxTaskHandle); return 0; } @@ -148,27 +212,41 @@ int32_t TelemetryInitialize(void) GCSTelemetryStatsInitialize(); // Initialize vars - timeOfLastObjectUpdate = 0; + timeOfLastObjectUpdate = 0; // Create object queues - queue = xQueueCreate(MAX_QUEUE_SIZE, sizeof(UAVObjEvent)); + telemHandle.mainQueue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); + radioHandle.mainQueue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); #if defined(PIOS_TELEM_PRIORITY_QUEUE) - priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, sizeof(UAVObjEvent)); -#endif + telemHandle.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); + radioHandle.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ // Update telemetry settings - telemetryPort = PIOS_COM_TELEM_RF; + telemHandle.telemetryPort = PIOS_COM_TELEM_RF; + #ifdef PIOS_INCLUDE_RFM22B - radioPort = PIOS_COM_RF; -#endif + radioHandle.telemetryPort = PIOS_COM_RF; +#else /* PIOS_INCLUDE_RFM22B */ + radioHandle.telemetryPort = 0; +#endif /* PIOS_INCLUDE_RFM22B */ +#ifdef PIOS_INCLUDE_USB + // if USB is connected, USB takes precedence for telemetry + if (PIOS_COM_Available(PIOS_COM_TELEM_USB)) { + radioHandle.telemetryPort = PIOS_COM_TELEM_USB; + } +#endif /* PIOS_INCLUDE_USB */ + HwSettingsInitialize(); updateSettings(); // Initialise UAVTalk - uavTalkCon = UAVTalkInitialize(&transmitData); -#ifdef PIOS_INCLUDE_RFM22B - radioUavTalkCon = UAVTalkInitialize(&transmitRadioData); -#endif + telemHandle.uavTalkCon = UAVTalkInitialize(&transmitData); + radioHandle.uavTalkCon = UAVTalkInitialize(&transmitRadioData); // Create periodic event that will be used to update the telemetry stats // FIXME STATS_UPDATE_PERIOD_MS is 4000ms while FlighTelemetryStats update period is 5000ms... @@ -176,7 +254,22 @@ int32_t TelemetryInitialize(void) txRetries = 0; UAVObjEvent ev; memset(&ev, 0, sizeof(UAVObjEvent)); - EventPeriodicQueueCreate(&ev, priorityQueue, STATS_UPDATE_PERIOD_MS); + +#ifdef PIOS_TELEM_PRIORITY_QUEUE + EventPeriodicQueueCreate(&ev, + telemHandle.priorityQueue, + STATS_UPDATE_PERIOD_MS); + EventPeriodicQueueCreate(&ev, + radioHandle.priorityQueue, + STATS_UPDATE_PERIOD_MS); +#else /* PIOS_TELEM_PRIORITY_QUEUE */ + EventPeriodicQueueCreate(&ev, + telemHandle.mainQueue, + STATS_UPDATE_PERIOD_MS); + EventPeriodicQueueCreate(&ev, + radioHandle.mainQueue, + STATS_UPDATE_PERIOD_MS); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ return 0; } @@ -188,14 +281,39 @@ MODULE_INITCALL(TelemetryInitialize, TelemetryStart); * telemetry settings. * \param[in] obj Object to connect */ -static void registerObject(UAVObjHandle obj) +static void registerTelemObject(UAVObjHandle obj) { if (UAVObjIsMetaobject(obj)) { // Only connect change notifications for meta objects. No periodic updates - UAVObjConnectQueue(obj, priorityQueue, EV_MASK_ALL_UPDATES); +#ifdef PIOS_TELEM_PRIORITY_QUEUE + UAVObjConnectQueue(obj, telemHandle.priorityQueue, EV_MASK_ALL_UPDATES); +#else /* PIOS_TELEM_PRIORITY_QUEUE */ + UAVObjConnectQueue(obj, telemHandle.mainQueue, EV_MASK_ALL_UPDATES); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ } else { // Setup object for periodic updates - updateObject(obj, EV_NONE); + updateObject( + &telemHandle, + obj, + EV_NONE); + } +} + +static void registerRadioObject(UAVObjHandle obj) +{ + if (UAVObjIsMetaobject(obj)) { + // Only connect change notifications for meta objects. No periodic updates +#ifdef PIOS_TELEM_PRIORITY_QUEUE + UAVObjConnectQueue(obj, radioHandle.priorityQueue, EV_MASK_ALL_UPDATES); +#else /* PIOS_TELEM_PRIORITY_QUEUE */ + UAVObjConnectQueue(obj, radioHandle.mainQueue, EV_MASK_ALL_UPDATES); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ + } else { + // Setup object for periodic updates + updateObject( + &radioHandle, + obj, + EV_NONE); } } @@ -203,7 +321,10 @@ static void registerObject(UAVObjHandle obj) * Update object's queue connections and timer, depending on object's settings * \param[in] obj Object to updates */ -static void updateObject(UAVObjHandle obj, int32_t eventType) +static void updateObject( + telemetryContext *telemetryHandle, + UAVObjHandle obj, + int32_t eventType) { UAVObjMetadata metadata; UAVObjUpdateMode updateMode, loggingMode; @@ -226,13 +347,15 @@ static void updateObject(UAVObjHandle obj, int32_t eventType) switch (updateMode) { case UPDATEMODE_PERIODIC: // Set update period - setUpdatePeriod(obj, metadata.telemetryUpdatePeriod); + setUpdatePeriod(telemetryHandle, + obj, + metadata.telemetryUpdatePeriod); // Connect queue eventMask |= EV_UPDATED_PERIODIC | EV_UPDATED_MANUAL | EV_UPDATE_REQ; break; case UPDATEMODE_ONCHANGE: // Set update period - setUpdatePeriod(obj, 0); + setUpdatePeriod(telemetryHandle, obj, 0); // Connect queue eventMask |= EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ; break; @@ -242,7 +365,9 @@ static void updateObject(UAVObjHandle obj, int32_t eventType) eventMask |= EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ; // Set update period on initialization and metadata change if (eventType == EV_NONE) { - setUpdatePeriod(obj, metadata.telemetryUpdatePeriod); + setUpdatePeriod(telemetryHandle, + obj, + metadata.telemetryUpdatePeriod); } } else { // Otherwise, we just received an object update, so switch to periodic for the timeout period to prevent more updates @@ -251,7 +376,7 @@ static void updateObject(UAVObjHandle obj, int32_t eventType) break; case UPDATEMODE_MANUAL: // Set update period - setUpdatePeriod(obj, 0); + setUpdatePeriod(telemetryHandle, obj, 0); // Connect queue eventMask |= EV_UPDATED_MANUAL | EV_UPDATE_REQ; break; @@ -259,13 +384,13 @@ static void updateObject(UAVObjHandle obj, int32_t eventType) switch (loggingMode) { case UPDATEMODE_PERIODIC: // Set update period - setLoggingPeriod(obj, metadata.loggingUpdatePeriod); + setLoggingPeriod(telemetryHandle, obj, metadata.loggingUpdatePeriod); // Connect queue eventMask |= EV_LOGGING_PERIODIC | EV_LOGGING_MANUAL; break; case UPDATEMODE_ONCHANGE: // Set update period - setLoggingPeriod(obj, 0); + setLoggingPeriod(telemetryHandle, obj, 0); // Connect queue eventMask |= EV_UPDATED | EV_LOGGING_MANUAL; break; @@ -275,7 +400,9 @@ static void updateObject(UAVObjHandle obj, int32_t eventType) eventMask |= EV_UPDATED | EV_LOGGING_MANUAL; // Set update period on initialization and metadata change if (eventType == EV_NONE) { - setLoggingPeriod(obj, metadata.loggingUpdatePeriod); + setLoggingPeriod(telemetryHandle, + obj, + metadata.loggingUpdatePeriod); } } else { // Otherwise, we just received an object update, so switch to periodic for the timeout period to prevent more updates @@ -284,23 +411,28 @@ static void updateObject(UAVObjHandle obj, int32_t eventType) break; case UPDATEMODE_MANUAL: // Set update period - setLoggingPeriod(obj, 0); + setLoggingPeriod(telemetryHandle, obj, 0); // Connect queue eventMask |= EV_LOGGING_MANUAL; break; } + // note that all setting objects have implicitly IsPriority=true +#ifdef PIOS_TELEM_PRIORITY_QUEUE if (UAVObjIsPriority(obj)) { - UAVObjConnectQueue(obj, priorityQueue, eventMask); - } else { - UAVObjConnectQueue(obj, queue, eventMask); - } + UAVObjConnectQueue(obj, telemetryHandle->priorityQueue, eventMask); + } else +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ + UAVObjConnectQueue(obj, telemetryHandle->mainQueue, eventMask); } + /** * Processes queue events */ -static void processObjEvent(UAVObjEvent *ev) +static void processObjEvent( + telemetryContext *telemetryHandle, + UAVObjEvent *ev) { UAVObjMetadata metadata; UAVObjUpdateMode updateMode; @@ -325,7 +457,10 @@ static void processObjEvent(UAVObjEvent *ev) // Send update to GCS (with retries) while (retries < MAX_RETRIES && success == -1) { // call blocks until ack is received or timeout - success = UAVTalkSendObject(uavTalkCon, ev->obj, ev->instId, UAVObjGetTelemetryAcked(&metadata), REQ_TIMEOUT_MS); + success = UAVTalkSendObject(telemetryHandle->uavTalkCon, + ev->obj, + ev->instId, + UAVObjGetTelemetryAcked(&metadata), REQ_TIMEOUT_MS); if (success == -1) { ++retries; } @@ -339,7 +474,10 @@ static void processObjEvent(UAVObjEvent *ev) // Request object update from GCS (with retries) while (retries < MAX_RETRIES && success == -1) { // call blocks until update is received or timeout - success = UAVTalkSendObjectRequest(uavTalkCon, ev->obj, ev->instId, REQ_TIMEOUT_MS); + success = UAVTalkSendObjectRequest(telemetryHandle->uavTalkCon, + ev->obj, + ev->instId, + REQ_TIMEOUT_MS); if (success == -1) { ++retries; } @@ -353,11 +491,17 @@ static void processObjEvent(UAVObjEvent *ev) // If this is a metaobject then make necessary telemetry updates if (UAVObjIsMetaobject(ev->obj)) { // linked object will be the actual object the metadata are for - updateObject(UAVObjGetLinkedObj(ev->obj), EV_NONE); + updateObject( + telemetryHandle, + UAVObjGetLinkedObj(ev->obj), + EV_NONE); } else { if (updateMode == UPDATEMODE_THROTTLED) { // If this is UPDATEMODE_THROTTLED, the event mask changes on every event. - updateObject(ev->obj, ev->event); + updateObject( + telemetryHandle, + ev->obj, + ev->event); } } } @@ -378,7 +522,10 @@ static void processObjEvent(UAVObjEvent *ev) } if (updateMode == UPDATEMODE_THROTTLED) { // If this is UPDATEMODE_THROTTLED, the event mask changes on every event. - updateObject(ev->obj, ev->event); + updateObject( + telemetryHandle, + ev->obj, + ev->event); } } } @@ -386,37 +533,43 @@ static void processObjEvent(UAVObjEvent *ev) /** * Telemetry transmit task, regular priority */ -static void telemetryTxTask(__attribute__((unused)) void *parameters) +static void telemetryTxTask(void *parameters) { + telemetryContext *telemetryHandle = (telemetryContext *)parameters; UAVObjEvent ev; + /* Check for a bad context */ + if (!telemetryHandle) { + return; + } + // Loop forever while (1) { /** * Tries to empty the high priority queue before handling any standard priority item */ -#if defined(PIOS_TELEM_PRIORITY_QUEUE) +#ifdef PIOS_TELEM_PRIORITY_QUEUE // empty priority queue, non-blocking - while (xQueueReceive(priorityQueue, &ev, 0) == pdTRUE) { + while (xQueueReceive(telemetryHandle->priorityQueue, &ev, 0) == pdTRUE) { // Process event - processObjEvent(&ev); + processObjEvent(telemetryHandle, &ev); } // check regular queue and process update - non-blocking - if (xQueueReceive(queue, &ev, 0) == pdTRUE) { + if (xQueueReceive(telemetryHandle->mainQueue, &ev, 0) == pdTRUE) { // Process event - processObjEvent(&ev); + processObjEvent(telemetryHandle, &ev); // if both queues are empty, wait on priority queue for updates (1 tick) then repeat cycle - } else if (xQueueReceive(priorityQueue, &ev, 1) == pdTRUE) { + } else if (xQueueReceive(telemetryHandle->priorityQueue, &ev, 1) == pdTRUE) { // Process event - processObjEvent(&ev); + processObjEvent(telemetryHandle, &ev); } #else // wait on queue for updates (1 tick) then repeat cycle - if (xQueueReceive(queue, &ev, 1) == pdTRUE) { + if (xQueueReceive(telemetryHandle->mainQueue, &ev, 1) == pdTRUE) { // Process event - processObjEvent(&ev); + processObjEvent(telemetryHandle, &ev); } -#endif /* if defined(PIOS_TELEM_PRIORITY_QUEUE) */ +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ } } @@ -424,11 +577,18 @@ static void telemetryTxTask(__attribute__((unused)) void *parameters) /** * Telemetry receive task. Processes queue events and periodic updates. */ -static void telemetryRxTask(__attribute__((unused)) void *parameters) +static void telemetryRxTask(void *parameters) { + telemetryContext *telemetryHandle = (telemetryContext *)parameters; + + /* Check for a bad context */ + if (!telemetryHandle) { + return; + } + // Task loop while (1) { - uint32_t inputPort = getComPort(true); + uint32_t inputPort = telemetryHandle->telemetryPort; if (inputPort) { // Block until data are available @@ -438,7 +598,7 @@ static void telemetryRxTask(__attribute__((unused)) void *parameters) bytes_to_process = PIOS_COM_ReceiveBuffer(inputPort, serial_data, sizeof(serial_data), 500); if (bytes_to_process > 0) { for (uint8_t i = 0; i < bytes_to_process; i++) { - UAVTalkProcessInputStream(uavTalkCon, serial_data[i]); + UAVTalkProcessInputStream(telemetryHandle->uavTalkCon, serial_data[i]); } } } else { @@ -447,46 +607,6 @@ static void telemetryRxTask(__attribute__((unused)) void *parameters) } } -#ifdef PIOS_INCLUDE_RFM22B -/** - * Radio telemetry receive task. Processes queue events and periodic updates. - */ -static void radioRxTask(__attribute__((unused)) void *parameters) -{ - // Task loop - while (1) { - if (radioPort) { - // Block until data are available - uint8_t serial_data[1]; - uint16_t bytes_to_process; - - bytes_to_process = PIOS_COM_ReceiveBuffer(radioPort, serial_data, sizeof(serial_data), 500); - if (bytes_to_process > 0) { - for (uint8_t i = 0; i < bytes_to_process; i++) { - UAVTalkProcessInputStream(radioUavTalkCon, serial_data[i]); - } - } - } else { - vTaskDelay(5); - } - } -} -/** - * Transmit data buffer to the radioport. - * \param[in] data Data buffer to send - * \param[in] length Length of buffer - * \return -1 on failure - * \return number of bytes transmitted on success - */ -static int32_t transmitRadioData(uint8_t *data, int32_t length) -{ - if (radioPort) { - return PIOS_COM_SendBuffer(radioPort, data, length); - } - - return -1; -} -#endif /* PIOS_INCLUDE_RFM22B */ /** * Transmit data buffer to the modem or USB port. @@ -497,7 +617,44 @@ static int32_t transmitRadioData(uint8_t *data, int32_t length) */ static int32_t transmitData(uint8_t *data, int32_t length) { - uint32_t outputPort = getComPort(false); + uint32_t outputPort; + + outputPort = PIOS_COM_TELEM_RF; + + // Anticipate next input on the port on which this output occurs + telemHandle.telemetryPort = outputPort; + + if (outputPort) { + return PIOS_COM_SendBuffer(outputPort, data, length); + } + + return -1; +} + + +/** + * Transmit data buffer to the radioport. + * \param[in] data Data buffer to send + * \param[in] length Length of buffer + * \return -1 on failure + * \return number of bytes transmitted on success + */ +static int32_t transmitRadioData(uint8_t *data, int32_t length) +{ +#ifdef PIOS_INCLUDE_RFM22B + uint32_t outputPort = PIOS_COM_RF; +#else /* PIOS_INCLUDE_RFM22B */ + uint32_t outputPort = 0; +#endif /* PIOS_INCLUDE_RFM22B */ +#ifdef PIOS_INCLUDE_USB + // if USB is connected, USB takes precedence for telemetry + if (PIOS_COM_Available(PIOS_COM_TELEM_USB)) { + outputPort = PIOS_COM_TELEM_USB; + } +#endif /* PIOS_INCLUDE_USB */ + + // Anticipate next input on the port on which this output occurs + radioHandle.telemetryPort = outputPort; if (outputPort) { return PIOS_COM_SendBuffer(outputPort, data, length); @@ -513,7 +670,10 @@ static int32_t transmitData(uint8_t *data, int32_t length) * \return 0 Success * \return -1 Failure */ -static int32_t setUpdatePeriod(UAVObjHandle obj, int32_t updatePeriodMs) +static int32_t setUpdatePeriod( + telemetryContext *telemetryHandle, + UAVObjHandle obj, + int32_t updatePeriodMs) { UAVObjEvent ev; int32_t ret; @@ -524,7 +684,12 @@ static int32_t setUpdatePeriod(UAVObjHandle obj, int32_t updatePeriodMs) ev.event = EV_UPDATED_PERIODIC; ev.lowPriority = true; - xQueueHandle targetQueue = UAVObjIsPriority(obj) ? priorityQueue : queue; +#ifdef PIOS_TELEM_PRIORITY_QUEUE + xQueueHandle targetQueue = UAVObjIsPriority(obj) ? telemetryHandle->priorityQueue : + telemetryHandle->mainQueue; +#else /* PIOS_TELEM_PRIORITY_QUEUE */ + xQueueHandle targetQueue = telemetryHandle->mainQueue; +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ ret = EventPeriodicQueueUpdate(&ev, targetQueue, updatePeriodMs); if (ret == -1) { @@ -540,7 +705,10 @@ static int32_t setUpdatePeriod(UAVObjHandle obj, int32_t updatePeriodMs) * \return 0 Success * \return -1 Failure */ -static int32_t setLoggingPeriod(UAVObjHandle obj, int32_t updatePeriodMs) +static int32_t setLoggingPeriod( + telemetryContext *telemetryHandle, + UAVObjHandle obj, + int32_t updatePeriodMs) { UAVObjEvent ev; int32_t ret; @@ -551,7 +719,12 @@ static int32_t setLoggingPeriod(UAVObjHandle obj, int32_t updatePeriodMs) ev.event = EV_LOGGING_PERIODIC; ev.lowPriority = true; - xQueueHandle targetQueue = UAVObjIsPriority(obj) ? priorityQueue : queue; +#ifdef PIOS_TELEM_PRIORITY_QUEUE + xQueueHandle targetQueue = UAVObjIsPriority(obj) ? telemetryHandle->priorityQueue : + telemetryHandle->mainQueue; +#else /* PIOS_TELEM_PRIORITY_QUEUE */ + xQueueHandle targetQueue = telemetryHandle->mainQueue; +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ ret = EventPeriodicQueueUpdate(&ev, targetQueue, updatePeriodMs); if (ret == -1) { @@ -590,10 +763,8 @@ static void updateTelemetryStats() uint32_t timeNow; // Get stats - UAVTalkGetStats(uavTalkCon, &utalkStats, true); -#ifdef PIOS_INCLUDE_RFM22B - UAVTalkAddStats(radioUavTalkCon, &utalkStats, true); -#endif + UAVTalkGetStats(telemHandle.uavTalkCon, &utalkStats, true); + UAVTalkAddStats(radioHandle.uavTalkCon, &utalkStats, true); // Get object data FlightTelemetryStatsGet(&flightStats); @@ -685,7 +856,7 @@ static void updateTelemetryStats() */ static void updateSettings() { - if (telemetryPort) { + if (telemHandle.telemetryPort) { // Retrieve settings uint8_t speed; HwSettingsTelemetrySpeedGet(&speed); @@ -693,58 +864,30 @@ static void updateSettings() // Set port speed switch (speed) { case HWSETTINGS_TELEMETRYSPEED_2400: - PIOS_COM_ChangeBaud(telemetryPort, 2400); + PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 2400); break; case HWSETTINGS_TELEMETRYSPEED_4800: - PIOS_COM_ChangeBaud(telemetryPort, 4800); + PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 4800); break; case HWSETTINGS_TELEMETRYSPEED_9600: - PIOS_COM_ChangeBaud(telemetryPort, 9600); + PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 9600); break; case HWSETTINGS_TELEMETRYSPEED_19200: - PIOS_COM_ChangeBaud(telemetryPort, 19200); + PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 19200); break; case HWSETTINGS_TELEMETRYSPEED_38400: - PIOS_COM_ChangeBaud(telemetryPort, 38400); + PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 38400); break; case HWSETTINGS_TELEMETRYSPEED_57600: - PIOS_COM_ChangeBaud(telemetryPort, 57600); + PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 57600); break; case HWSETTINGS_TELEMETRYSPEED_115200: - PIOS_COM_ChangeBaud(telemetryPort, 115200); + PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 115200); break; } } } -/** - * Determine input/output com port as highest priority available - * @param[in] input Returns the approproate input com port if true, else the appropriate output com port - */ -#ifdef PIOS_INCLUDE_RFM22B -static uint32_t getComPort(bool input) -#else -static uint32_t getComPort(__attribute__((unused)) bool input) -#endif -{ -#if defined(PIOS_INCLUDE_USB) - // if USB is connected, USB takes precedence for telemetry - if (PIOS_COM_Available(PIOS_COM_TELEM_USB)) { - return PIOS_COM_TELEM_USB; - } else -#endif /* PIOS_INCLUDE_USB */ -#ifdef PIOS_INCLUDE_RFM22B - // PIOS_COM_RF input is handled by a separate RX thread and therefore must be ignored - if (input && telemetryPort == PIOS_COM_RF) { - return 0; - } else -#endif /* PIOS_INCLUDE_RFM22B */ - if (PIOS_COM_Available(telemetryPort)) { - return telemetryPort; - } else { - return 0; - } -} /** * @} diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index da954a045..35f218a75 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -740,10 +740,7 @@ void PIOS_Board_Init(void) tx_buffer, PIOS_COM_RFM22B_RF_TX_BUF_LEN)) { PIOS_Assert(0); } - /* Set Telemetry to use OPLinkMini if no other telemetry is configured (USB always overrides anyway) */ - if (!pios_com_telem_rf_id) { - pios_com_telem_rf_id = pios_com_rf_id; - } + oplinkStatus.LinkState = OPLINKSTATUS_LINKSTATE_ENABLED; // Set the RF data rate on the modem to ~2X the selected buad rate because the modem is half duplex. From 5952cfa27574cef575b88c4cb04dcc7fa76e8d59 Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Sun, 15 Mar 2015 00:48:36 +0000 Subject: [PATCH 11/44] Year is 2015 --- flight/modules/Telemetry/telemetry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index c5c2350e7..3ef5bbecd 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -9,7 +9,7 @@ * @{ * * @file telemetry.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015. * @brief Telemetry module, handles telemetry and UAVObject updates * @see The GNU Public License (GPL) Version 3 * From f1e1507b06751db24ca1be176d5c41c3ae707140 Mon Sep 17 00:00:00 2001 From: m_thread Date: Sun, 15 Mar 2015 12:18:14 +0100 Subject: [PATCH 12/44] OP-1777 Added more settings information. Re-factored field access code. Added hash for integrity checks. --- .../usagetracker/usagetrackerplugin.cpp | 60 +++++++++++++++---- .../plugins/usagetracker/usagetrackerplugin.h | 2 + 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index 23a65b1b3..b09b35f36 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -33,15 +33,11 @@ #include #include #include -#include -#include #include #include #include #include "version_info/version_info.h" #include "coreplugin/icore.h" -#include "qmainwindow.h" -#include "manualcontrolsettings.h" UsageTrackerPlugin::UsageTrackerPlugin() : m_telemetryManager(NULL) @@ -140,8 +136,10 @@ void UsageTrackerPlugin::trackUsage() iter.next(); query.addQueryItem(iter.key(), iter.value()); } - qDebug() << "Parameters unencoded:" << query.toString(); - qDebug() << "Parameters encoded:" << query.toString(QUrl::FullyEncoded); + + // Add checksum + query.addQueryItem("hash", getQueryHash(query.toString())); + QUrl url("https://www.openpilot.org/opver?" + query.toString(QUrl::FullyEncoded)); qDebug() << "Sending usage tracking as:" << url.toEncoded(QUrl::FullyEncoded); networkAccessManager->get(QNetworkRequest(QUrl(url.toEncoded(QUrl::FullyEncoded)))); @@ -163,19 +161,55 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete parameters["fw_tag"] = devDesc.gitTag; parameters["fw_hash"] = devDesc.gitHash; parameters["os_version"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); + parameters["os_threads"] = QString::number(QThread::idealThreadCount()); parameters["gcs_version"] = VersionInfo::revision(); parameters["localtime"] = QDateTime::currentDateTime().toString(Qt::ISODate); // Configuration parameters - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject(); - ManualControlSettings *controlSettings = ManualControlSettings::GetInstance(objManager); - parameters["settings_receiver"] = controlSettings->getField("ChannelGroups")->getValue(ManualControlSettings::CHANNELGROUPS_THROTTLE).toString(); - RevoSettings *revoSettings = RevoSettings::GetInstance(objManager); - // Only get this info if uavo is known by controller - if (revoSettings->isKnown()) { - parameters["settings_fusion"] = revoSettings->getField("FusionAlgorithm")->getValue().toString(); + parameters["settings_receiver"] = getUAVFieldValue(objManager, "ManualControlSettings", "ChannelGroups", 0); + parameters["settings_vehicle"] = getUAVFieldValue(objManager, "SystemSettings", "AirframeType"); + + if ((boardModel & 0xff00) == 0x0400) { + // CopterControl family + parameters["settings_rport"] = getUAVFieldValue(objManager, "HwSettings", "CC_RcvrPort"); + parameters["settings_mport"] = getUAVFieldValue(objManager, "HwSettings", "CC_MainPort"); + parameters["settings_fport"] = getUAVFieldValue(objManager, "HwSettings", "CC_FlexiPort"); + } else if ((boardModel & 0xff00) == 0x0900) { + // Revolution family + parameters["settings_rport"] = getUAVFieldValue(objManager, "HwSettings", "RM_RcvrPort"); + parameters["settings_mport"] = getUAVFieldValue(objManager, "HwSettings", "RM_MainPort"); + parameters["settings_fport"] = getUAVFieldValue(objManager, "HwSettings", "RM_FlexiPort"); + parameters["settings_fusion"] = getUAVFieldValue(objManager, "RevoSettings", "FusionAlgorithm"); } + + parameters["settings_uport"] = getUAVFieldValue(objManager, "HwSettings", "USB_HIDPort"); + parameters["settings_vport"] = getUAVFieldValue(objManager, "HwSettings", "USB_VCPPort"); + + parameters["settings_rotation"] = QString("%1:%2:%3") + .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 0)) + .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 1)) + .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 2)); } } + +QString UsageTrackerPlugin::getUAVFieldValue(UAVObjectManager *objManager, QString objectName, QString fieldName, int index) const +{ + UAVObject *object = objManager->getObject(objectName); + + if (object != NULL) { + UAVObjectField *field = object->getField(fieldName); + if (field != NULL) { + return field->getValue(index).toString(); + } + } + return tr("Unknown"); +} + +QString UsageTrackerPlugin::getQueryHash(QString source) const +{ + source += "OpenPilot Fuck Yeah!"; + return QString(QCryptographicHash::hash(QByteArray(source.toStdString().c_str()), QCryptographicHash::Md5).toHex()); +} diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h index b06f1a325..1767cf274 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h @@ -48,6 +48,8 @@ private slots: private: TelemetryManager *m_telemetryManager; + QString getUAVFieldValue(UAVObjectManager *objManager, QString objectName, QString fieldName, int index = 0) const; + QString getQueryHash(QString source) const; }; #endif // USAGETRACKERPLUGIN_H From 12d3bdbe8ada6e7e231c3c1db0097bcc89304a78 Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Sun, 15 Mar 2015 18:19:19 +0000 Subject: [PATCH 13/44] OP-1289 add per channel port selection routines +review OPReview-985 --- flight/modules/Telemetry/telemetry.c | 114 +++++++++++++++------------ 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index 3ef5bbecd..83be2e424 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -93,14 +93,14 @@ // Private types typedef struct { - // Port on which to communicate telemetry information - uint32_t telemetryPort; + // Determine port on which to communicate telemetry information + uint32_t (*telemetryPort)(); // Main telemetry queue xQueueHandle mainQueue; - #ifdef PIOS_TELEM_PRIORITY_QUEUE +#ifdef PIOS_TELEM_PRIORITY_QUEUE // Priority telemetry queue xQueueHandle priorityQueue; - #endif /* PIOS_TELEM_PRIORITY_QUEUE */ +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ // Transmit/receive task handles xTaskHandle telemetryTxTaskHandle; xTaskHandle telemetryRxTaskHandle; @@ -108,15 +108,17 @@ typedef struct { UAVTalkConnection uavTalkCon; } telemetryContext; -// Main telemetry port +// Main telemetry channel static telemetryContext telemHandle; static int32_t transmitData(uint8_t *data, int32_t length); static void registerTelemObject(UAVObjHandle obj); +static uint32_t telemPort(); -// OPLink telemetry port +// OPLink telemetry channel static telemetryContext radioHandle; static int32_t transmitRadioData(uint8_t *data, int32_t length); static void registerRadioObject(UAVObjHandle obj); +static uint32_t radioPort(); // Telemetry stats static uint32_t txErrors; @@ -142,7 +144,7 @@ static int32_t setLoggingPeriod( int32_t updatePeriodMs); static void updateTelemetryStats(); static void gcsTelemetryStatsUpdated(); -static void updateSettings(); +static void updateSettings(telemetryContext *telemetryHandle); /** * Initialise the telemetry module @@ -226,23 +228,12 @@ int32_t TelemetryInitialize(void) sizeof(UAVObjEvent)); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ - // Update telemetry settings - telemHandle.telemetryPort = PIOS_COM_TELEM_RF; - -#ifdef PIOS_INCLUDE_RFM22B - radioHandle.telemetryPort = PIOS_COM_RF; -#else /* PIOS_INCLUDE_RFM22B */ - radioHandle.telemetryPort = 0; -#endif /* PIOS_INCLUDE_RFM22B */ -#ifdef PIOS_INCLUDE_USB - // if USB is connected, USB takes precedence for telemetry - if (PIOS_COM_Available(PIOS_COM_TELEM_USB)) { - radioHandle.telemetryPort = PIOS_COM_TELEM_USB; - } -#endif /* PIOS_INCLUDE_USB */ + // Set channel port handlers + telemHandle.telemetryPort = telemPort; + radioHandle.telemetryPort = radioPort; HwSettingsInitialize(); - updateSettings(); + updateSettings(&telemHandle); // Initialise UAVTalk telemHandle.uavTalkCon = UAVTalkInitialize(&transmitData); @@ -319,6 +310,7 @@ static void registerRadioObject(UAVObjHandle obj) /** * Update object's queue connections and timer, depending on object's settings + * \param[in] telemetry channel context * \param[in] obj Object to updates */ static void updateObject( @@ -588,7 +580,7 @@ static void telemetryRxTask(void *parameters) // Task loop while (1) { - uint32_t inputPort = telemetryHandle->telemetryPort; + uint32_t inputPort = telemetryHandle->telemetryPort(); if (inputPort) { // Block until data are available @@ -608,6 +600,38 @@ static void telemetryRxTask(void *parameters) } +/** + * Determine the port to be used for communication on the telemetry channel + * \return com port number + */ +static uint32_t telemPort() +{ + return PIOS_COM_TELEM_RF; +} + + +/** + * Determine the port to be used for communication on the radio channel + * \return com port number + */ +static uint32_t radioPort() +{ +#ifdef PIOS_INCLUDE_RFM22B + uint32_t port = PIOS_COM_RF; +#else /* PIOS_INCLUDE_RFM22B */ + uint32_t port = 0; +#endif /* PIOS_INCLUDE_RFM22B */ +#ifdef PIOS_INCLUDE_USB + // if USB is connected, USB takes precedence for telemetry + if (PIOS_COM_Available(PIOS_COM_TELEM_USB)) { + port = PIOS_COM_TELEM_USB; + } +#endif /* PIOS_INCLUDE_USB */ + + return port; +} + + /** * Transmit data buffer to the modem or USB port. * \param[in] data Data buffer to send @@ -617,12 +641,7 @@ static void telemetryRxTask(void *parameters) */ static int32_t transmitData(uint8_t *data, int32_t length) { - uint32_t outputPort; - - outputPort = PIOS_COM_TELEM_RF; - - // Anticipate next input on the port on which this output occurs - telemHandle.telemetryPort = outputPort; + uint32_t outputPort = telemHandle.telemetryPort(); if (outputPort) { return PIOS_COM_SendBuffer(outputPort, data, length); @@ -641,20 +660,7 @@ static int32_t transmitData(uint8_t *data, int32_t length) */ static int32_t transmitRadioData(uint8_t *data, int32_t length) { -#ifdef PIOS_INCLUDE_RFM22B - uint32_t outputPort = PIOS_COM_RF; -#else /* PIOS_INCLUDE_RFM22B */ - uint32_t outputPort = 0; -#endif /* PIOS_INCLUDE_RFM22B */ -#ifdef PIOS_INCLUDE_USB - // if USB is connected, USB takes precedence for telemetry - if (PIOS_COM_Available(PIOS_COM_TELEM_USB)) { - outputPort = PIOS_COM_TELEM_USB; - } -#endif /* PIOS_INCLUDE_USB */ - - // Anticipate next input on the port on which this output occurs - radioHandle.telemetryPort = outputPort; + uint32_t outputPort = radioHandle.telemetryPort(); if (outputPort) { return PIOS_COM_SendBuffer(outputPort, data, length); @@ -665,6 +671,7 @@ static int32_t transmitRadioData(uint8_t *data, int32_t length) /** * Set update period of object (it must be already setup for periodic updates) + * \param[in] telemetry channel context * \param[in] obj The object to update * \param[in] updatePeriodMs The update period in ms, if zero then periodic updates are disabled * \return 0 Success @@ -700,6 +707,7 @@ static int32_t setUpdatePeriod( /** * Set logging update period of object (it must be already setup for periodic updates) + * \param[in] telemetry channel context * \param[in] obj The object to update * \param[in] updatePeriodMs The update period in ms, if zero then periodic updates are disabled * \return 0 Success @@ -854,9 +862,11 @@ static void updateTelemetryStats() * settings, etc. Thus the HwSettings object which contains the * telemetry port speed is used for now. */ -static void updateSettings() +static void updateSettings(telemetryContext *telemetryHandle) { - if (telemHandle.telemetryPort) { + uint32_t port = telemetryHandle->telemetryPort(); + + if (port) { // Retrieve settings uint8_t speed; HwSettingsTelemetrySpeedGet(&speed); @@ -864,25 +874,25 @@ static void updateSettings() // Set port speed switch (speed) { case HWSETTINGS_TELEMETRYSPEED_2400: - PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 2400); + PIOS_COM_ChangeBaud(port, 2400); break; case HWSETTINGS_TELEMETRYSPEED_4800: - PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 4800); + PIOS_COM_ChangeBaud(port, 4800); break; case HWSETTINGS_TELEMETRYSPEED_9600: - PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 9600); + PIOS_COM_ChangeBaud(port, 9600); break; case HWSETTINGS_TELEMETRYSPEED_19200: - PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 19200); + PIOS_COM_ChangeBaud(port, 19200); break; case HWSETTINGS_TELEMETRYSPEED_38400: - PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 38400); + PIOS_COM_ChangeBaud(port, 38400); break; case HWSETTINGS_TELEMETRYSPEED_57600: - PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 57600); + PIOS_COM_ChangeBaud(port, 57600); break; case HWSETTINGS_TELEMETRYSPEED_115200: - PIOS_COM_ChangeBaud(telemHandle.telemetryPort, 115200); + PIOS_COM_ChangeBaud(port, 115200); break; } } From efccabfe8f71642303af948fe6acf41cb0835a33 Mon Sep 17 00:00:00 2001 From: m_thread Date: Sun, 15 Mar 2015 23:21:43 +0100 Subject: [PATCH 14/44] OP-1777 Renamed some parameters. --- .../usagetracker/usagetrackerplugin.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index b09b35f36..3650826a9 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -169,26 +169,26 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject(); - parameters["settings_receiver"] = getUAVFieldValue(objManager, "ManualControlSettings", "ChannelGroups", 0); - parameters["settings_vehicle"] = getUAVFieldValue(objManager, "SystemSettings", "AirframeType"); + parameters["conf_receiver"] = getUAVFieldValue(objManager, "ManualControlSettings", "ChannelGroups", 0); + parameters["conf_vehicle"] = getUAVFieldValue(objManager, "SystemSettings", "AirframeType"); if ((boardModel & 0xff00) == 0x0400) { // CopterControl family - parameters["settings_rport"] = getUAVFieldValue(objManager, "HwSettings", "CC_RcvrPort"); - parameters["settings_mport"] = getUAVFieldValue(objManager, "HwSettings", "CC_MainPort"); - parameters["settings_fport"] = getUAVFieldValue(objManager, "HwSettings", "CC_FlexiPort"); + parameters["conf_rport"] = getUAVFieldValue(objManager, "HwSettings", "CC_RcvrPort"); + parameters["conf_mport"] = getUAVFieldValue(objManager, "HwSettings", "CC_MainPort"); + parameters["conf_fport"] = getUAVFieldValue(objManager, "HwSettings", "CC_FlexiPort"); } else if ((boardModel & 0xff00) == 0x0900) { // Revolution family - parameters["settings_rport"] = getUAVFieldValue(objManager, "HwSettings", "RM_RcvrPort"); - parameters["settings_mport"] = getUAVFieldValue(objManager, "HwSettings", "RM_MainPort"); - parameters["settings_fport"] = getUAVFieldValue(objManager, "HwSettings", "RM_FlexiPort"); - parameters["settings_fusion"] = getUAVFieldValue(objManager, "RevoSettings", "FusionAlgorithm"); + parameters["conf_rport"] = getUAVFieldValue(objManager, "HwSettings", "RM_RcvrPort"); + parameters["conf_mport"] = getUAVFieldValue(objManager, "HwSettings", "RM_MainPort"); + parameters["conf_fport"] = getUAVFieldValue(objManager, "HwSettings", "RM_FlexiPort"); + parameters["conf_fusion"] = getUAVFieldValue(objManager, "RevoSettings", "FusionAlgorithm"); } - parameters["settings_uport"] = getUAVFieldValue(objManager, "HwSettings", "USB_HIDPort"); - parameters["settings_vport"] = getUAVFieldValue(objManager, "HwSettings", "USB_VCPPort"); + parameters["conf_uport"] = getUAVFieldValue(objManager, "HwSettings", "USB_HIDPort"); + parameters["conf_vport"] = getUAVFieldValue(objManager, "HwSettings", "USB_VCPPort"); - parameters["settings_rotation"] = QString("%1:%2:%3") + parameters["conf_rotation"] = QString("%1:%2:%3") .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 0)) .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 1)) .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 2)); From 45005a167f4f253cbb07ce0f210bbe786baa358d Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Sun, 15 Mar 2015 23:11:42 +0000 Subject: [PATCH 15/44] OP-1289 Revise naming of the two channels of data and associated functions The code now uses a "local" prefix to refer to the telemetry channel associated with a port on the FC and a "radio" prefix to refer to the telemetry channel associated with the OPLink/USB. +review OPReview-985 --- flight/modules/Telemetry/telemetry.c | 218 ++++++++++++++------------- 1 file changed, 111 insertions(+), 107 deletions(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index 83be2e424..6f6a4e0d9 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -35,11 +35,15 @@ * radio connection, called "RadioTx" and "Radio Rx", the latter being * overridden by USB if connected. * - * The telemetry port to use is defined by PIOS_COM_TELEM_RF in + * The following code uses a "local" prefix to refer to the telemetry channel + * associated with a port on the FC and a "radio" prefix to refer to the + * telemetry channel associated with the OPLink/USB. + * + * The "local" telemetry port to use is defined by PIOS_COM_TELEM_RF in * PIOS_Board_Init(). * - * A UAVTalk connection instance, telemUavTalkCon, is associated with the main - * telemetry channel and another, radioUavTalkCon, with the radio channel. + * A UAVTalk connection instance, telemUavTalkCon, is associated with the + * "local" channel and another, radioUavTalkCon, with the "radio" channel. * Associated with each instance is a transmit routine which will send data * to the appropriate port. * @@ -51,7 +55,7 @@ * the normal queue, passing each event to processObjEvent() which ultimately * passes each event to the UAVTalk library which results in the appropriate * transmit routine being called to send the data back to the recipient on - * the telemetry or radio link. + * the "local" or "radio" link. */ #include @@ -94,7 +98,7 @@ // Private types typedef struct { // Determine port on which to communicate telemetry information - uint32_t (*telemetryPort)(); + uint32_t (*getPort)(); // Main telemetry queue xQueueHandle mainQueue; #ifdef PIOS_TELEM_PRIORITY_QUEUE @@ -102,20 +106,20 @@ typedef struct { xQueueHandle priorityQueue; #endif /* PIOS_TELEM_PRIORITY_QUEUE */ // Transmit/receive task handles - xTaskHandle telemetryTxTaskHandle; - xTaskHandle telemetryRxTaskHandle; + xTaskHandle txTaskHandle; + xTaskHandle rxTaskHandle; // Telemetry stream UAVTalkConnection uavTalkCon; -} telemetryContext; +} channelContext; // Main telemetry channel -static telemetryContext telemHandle; -static int32_t transmitData(uint8_t *data, int32_t length); -static void registerTelemObject(UAVObjHandle obj); -static uint32_t telemPort(); +static channelContext localChannel; +static int32_t transmitLocalData(uint8_t *data, int32_t length); +static void registerLocalObject(UAVObjHandle obj); +static uint32_t localPort(); // OPLink telemetry channel -static telemetryContext radioHandle; +static channelContext radioChannel; static int32_t transmitRadioData(uint8_t *data, int32_t length); static void registerRadioObject(UAVObjHandle obj); static uint32_t radioPort(); @@ -128,23 +132,23 @@ static uint32_t timeOfLastObjectUpdate; static void telemetryTxTask(void *parameters); static void telemetryRxTask(void *parameters); static void updateObject( - telemetryContext *telemetryHandle, + channelContext *channel, UAVObjHandle obj, int32_t eventType); static void processObjEvent( - telemetryContext *telemetryHandle, + channelContext *channel, UAVObjEvent *ev); static int32_t setUpdatePeriod( - telemetryContext *telemetryHandle, + channelContext *channel, UAVObjHandle obj, int32_t updatePeriodMs); static int32_t setLoggingPeriod( - telemetryContext *telemetryHandle, + channelContext *channel, UAVObjHandle obj, int32_t updatePeriodMs); static void updateTelemetryStats(); static void gcsTelemetryStatsUpdated(); -static void updateSettings(telemetryContext *telemetryHandle); +static void updateSettings(channelContext *channel); /** * Initialise the telemetry module @@ -153,52 +157,52 @@ static void updateSettings(telemetryContext *telemetryHandle); */ int32_t TelemetryStart(void) { - UAVObjIterate(®isterTelemObject); + UAVObjIterate(®isterLocalObject); UAVObjIterate(®isterRadioObject); // Listen to objects of interest #ifdef PIOS_TELEM_PRIORITY_QUEUE - GCSTelemetryStatsConnectQueue(telemHandle.priorityQueue); - GCSTelemetryStatsConnectQueue(radioHandle.priorityQueue); + GCSTelemetryStatsConnectQueue(localChannel.priorityQueue); + GCSTelemetryStatsConnectQueue(radioChannel.priorityQueue); #else /* PIOS_TELEM_PRIORITY_QUEUE */ - GCSTelemetryStatsConnectQueue(telemHandle.mainQueue); - GCSTelemetryStatsConnectQueue(radioHandle.mainQueue); + GCSTelemetryStatsConnectQueue(localChannel.mainQueue); + GCSTelemetryStatsConnectQueue(radioChannel.mainQueue); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ // Start telemetry tasks xTaskCreate(telemetryTxTask, "TelTx", STACK_SIZE_TX_BYTES / 4, - &telemHandle, + &localChannel, TASK_PRIORITY_TX, - &telemHandle.telemetryTxTaskHandle); + &localChannel.txTaskHandle); PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, - telemHandle.telemetryTxTaskHandle); + localChannel.txTaskHandle); xTaskCreate(telemetryRxTask, "TelRx", STACK_SIZE_RX_BYTES / 4, - &telemHandle, + &localChannel, TASK_PRIORITY_RX, - &telemHandle.telemetryRxTaskHandle); + &localChannel.rxTaskHandle); PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX, - telemHandle.telemetryRxTaskHandle); + localChannel.rxTaskHandle); xTaskCreate(telemetryTxTask, "RadioTx", STACK_SIZE_RADIO_TX_BYTES / 4, - &radioHandle, + &radioChannel, TASK_PRIORITY_RADTX, - &radioHandle.telemetryTxTaskHandle); + &radioChannel.txTaskHandle); PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, - radioHandle.telemetryTxTaskHandle); + radioChannel.txTaskHandle); xTaskCreate(telemetryRxTask, "RadioRx", STACK_SIZE_RADIO_RX_BYTES / 4, - &radioHandle, + &radioChannel, TASK_PRIORITY_RADRX, - &radioHandle.telemetryRxTaskHandle); + &radioChannel.rxTaskHandle); PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_RADIORX, - radioHandle.telemetryRxTaskHandle); + radioChannel.rxTaskHandle); return 0; } @@ -214,30 +218,30 @@ int32_t TelemetryInitialize(void) GCSTelemetryStatsInitialize(); // Initialize vars - timeOfLastObjectUpdate = 0; + timeOfLastObjectUpdate = 0; // Create object queues - telemHandle.mainQueue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); - radioHandle.mainQueue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); + localChannel.mainQueue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); + radioChannel.mainQueue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); #if defined(PIOS_TELEM_PRIORITY_QUEUE) - telemHandle.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); - radioHandle.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); + localChannel.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); + radioChannel.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ // Set channel port handlers - telemHandle.telemetryPort = telemPort; - radioHandle.telemetryPort = radioPort; + localChannel.getPort = localPort; + radioChannel.getPort = radioPort; HwSettingsInitialize(); - updateSettings(&telemHandle); + updateSettings(&localChannel); // Initialise UAVTalk - telemHandle.uavTalkCon = UAVTalkInitialize(&transmitData); - radioHandle.uavTalkCon = UAVTalkInitialize(&transmitRadioData); + localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData); + radioChannel.uavTalkCon = UAVTalkInitialize(&transmitRadioData); // Create periodic event that will be used to update the telemetry stats // FIXME STATS_UPDATE_PERIOD_MS is 4000ms while FlighTelemetryStats update period is 5000ms... @@ -248,17 +252,17 @@ int32_t TelemetryInitialize(void) #ifdef PIOS_TELEM_PRIORITY_QUEUE EventPeriodicQueueCreate(&ev, - telemHandle.priorityQueue, + localChannel.priorityQueue, STATS_UPDATE_PERIOD_MS); EventPeriodicQueueCreate(&ev, - radioHandle.priorityQueue, + radioChannel.priorityQueue, STATS_UPDATE_PERIOD_MS); #else /* PIOS_TELEM_PRIORITY_QUEUE */ EventPeriodicQueueCreate(&ev, - telemHandle.mainQueue, + localChannel.mainQueue, STATS_UPDATE_PERIOD_MS); EventPeriodicQueueCreate(&ev, - radioHandle.mainQueue, + radioChannel.mainQueue, STATS_UPDATE_PERIOD_MS); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ @@ -272,19 +276,19 @@ MODULE_INITCALL(TelemetryInitialize, TelemetryStart); * telemetry settings. * \param[in] obj Object to connect */ -static void registerTelemObject(UAVObjHandle obj) +static void registerLocalObject(UAVObjHandle obj) { if (UAVObjIsMetaobject(obj)) { // Only connect change notifications for meta objects. No periodic updates #ifdef PIOS_TELEM_PRIORITY_QUEUE - UAVObjConnectQueue(obj, telemHandle.priorityQueue, EV_MASK_ALL_UPDATES); + UAVObjConnectQueue(obj, localChannel.priorityQueue, EV_MASK_ALL_UPDATES); #else /* PIOS_TELEM_PRIORITY_QUEUE */ - UAVObjConnectQueue(obj, telemHandle.mainQueue, EV_MASK_ALL_UPDATES); + UAVObjConnectQueue(obj, localChannel.mainQueue, EV_MASK_ALL_UPDATES); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ } else { // Setup object for periodic updates updateObject( - &telemHandle, + &localChannel, obj, EV_NONE); } @@ -295,14 +299,14 @@ static void registerRadioObject(UAVObjHandle obj) if (UAVObjIsMetaobject(obj)) { // Only connect change notifications for meta objects. No periodic updates #ifdef PIOS_TELEM_PRIORITY_QUEUE - UAVObjConnectQueue(obj, radioHandle.priorityQueue, EV_MASK_ALL_UPDATES); + UAVObjConnectQueue(obj, radioChannel.priorityQueue, EV_MASK_ALL_UPDATES); #else /* PIOS_TELEM_PRIORITY_QUEUE */ - UAVObjConnectQueue(obj, radioHandle.mainQueue, EV_MASK_ALL_UPDATES); + UAVObjConnectQueue(obj, radioChannel.mainQueue, EV_MASK_ALL_UPDATES); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ } else { // Setup object for periodic updates updateObject( - &radioHandle, + &radioChannel, obj, EV_NONE); } @@ -314,7 +318,7 @@ static void registerRadioObject(UAVObjHandle obj) * \param[in] obj Object to updates */ static void updateObject( - telemetryContext *telemetryHandle, + channelContext *channel, UAVObjHandle obj, int32_t eventType) { @@ -339,7 +343,7 @@ static void updateObject( switch (updateMode) { case UPDATEMODE_PERIODIC: // Set update period - setUpdatePeriod(telemetryHandle, + setUpdatePeriod(channel, obj, metadata.telemetryUpdatePeriod); // Connect queue @@ -347,7 +351,7 @@ static void updateObject( break; case UPDATEMODE_ONCHANGE: // Set update period - setUpdatePeriod(telemetryHandle, obj, 0); + setUpdatePeriod(channel, obj, 0); // Connect queue eventMask |= EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ; break; @@ -357,7 +361,7 @@ static void updateObject( eventMask |= EV_UPDATED | EV_UPDATED_MANUAL | EV_UPDATE_REQ; // Set update period on initialization and metadata change if (eventType == EV_NONE) { - setUpdatePeriod(telemetryHandle, + setUpdatePeriod(channel, obj, metadata.telemetryUpdatePeriod); } @@ -368,7 +372,7 @@ static void updateObject( break; case UPDATEMODE_MANUAL: // Set update period - setUpdatePeriod(telemetryHandle, obj, 0); + setUpdatePeriod(channel, obj, 0); // Connect queue eventMask |= EV_UPDATED_MANUAL | EV_UPDATE_REQ; break; @@ -376,13 +380,13 @@ static void updateObject( switch (loggingMode) { case UPDATEMODE_PERIODIC: // Set update period - setLoggingPeriod(telemetryHandle, obj, metadata.loggingUpdatePeriod); + setLoggingPeriod(channel, obj, metadata.loggingUpdatePeriod); // Connect queue eventMask |= EV_LOGGING_PERIODIC | EV_LOGGING_MANUAL; break; case UPDATEMODE_ONCHANGE: // Set update period - setLoggingPeriod(telemetryHandle, obj, 0); + setLoggingPeriod(channel, obj, 0); // Connect queue eventMask |= EV_UPDATED | EV_LOGGING_MANUAL; break; @@ -392,7 +396,7 @@ static void updateObject( eventMask |= EV_UPDATED | EV_LOGGING_MANUAL; // Set update period on initialization and metadata change if (eventType == EV_NONE) { - setLoggingPeriod(telemetryHandle, + setLoggingPeriod(channel, obj, metadata.loggingUpdatePeriod); } @@ -403,7 +407,7 @@ static void updateObject( break; case UPDATEMODE_MANUAL: // Set update period - setLoggingPeriod(telemetryHandle, obj, 0); + setLoggingPeriod(channel, obj, 0); // Connect queue eventMask |= EV_LOGGING_MANUAL; break; @@ -412,10 +416,10 @@ static void updateObject( // note that all setting objects have implicitly IsPriority=true #ifdef PIOS_TELEM_PRIORITY_QUEUE if (UAVObjIsPriority(obj)) { - UAVObjConnectQueue(obj, telemetryHandle->priorityQueue, eventMask); + UAVObjConnectQueue(obj, channel->priorityQueue, eventMask); } else #endif /* PIOS_TELEM_PRIORITY_QUEUE */ - UAVObjConnectQueue(obj, telemetryHandle->mainQueue, eventMask); + UAVObjConnectQueue(obj, channel->mainQueue, eventMask); } @@ -423,7 +427,7 @@ static void updateObject( * Processes queue events */ static void processObjEvent( - telemetryContext *telemetryHandle, + channelContext *channel, UAVObjEvent *ev) { UAVObjMetadata metadata; @@ -449,7 +453,7 @@ static void processObjEvent( // Send update to GCS (with retries) while (retries < MAX_RETRIES && success == -1) { // call blocks until ack is received or timeout - success = UAVTalkSendObject(telemetryHandle->uavTalkCon, + success = UAVTalkSendObject(channel->uavTalkCon, ev->obj, ev->instId, UAVObjGetTelemetryAcked(&metadata), REQ_TIMEOUT_MS); @@ -466,7 +470,7 @@ static void processObjEvent( // Request object update from GCS (with retries) while (retries < MAX_RETRIES && success == -1) { // call blocks until update is received or timeout - success = UAVTalkSendObjectRequest(telemetryHandle->uavTalkCon, + success = UAVTalkSendObjectRequest(channel->uavTalkCon, ev->obj, ev->instId, REQ_TIMEOUT_MS); @@ -484,14 +488,14 @@ static void processObjEvent( if (UAVObjIsMetaobject(ev->obj)) { // linked object will be the actual object the metadata are for updateObject( - telemetryHandle, + channel, UAVObjGetLinkedObj(ev->obj), EV_NONE); } else { if (updateMode == UPDATEMODE_THROTTLED) { // If this is UPDATEMODE_THROTTLED, the event mask changes on every event. updateObject( - telemetryHandle, + channel, ev->obj, ev->event); } @@ -515,7 +519,7 @@ static void processObjEvent( if (updateMode == UPDATEMODE_THROTTLED) { // If this is UPDATEMODE_THROTTLED, the event mask changes on every event. updateObject( - telemetryHandle, + channel, ev->obj, ev->event); } @@ -527,11 +531,11 @@ static void processObjEvent( */ static void telemetryTxTask(void *parameters) { - telemetryContext *telemetryHandle = (telemetryContext *)parameters; + channelContext *channel = (channelContext *)parameters; UAVObjEvent ev; /* Check for a bad context */ - if (!telemetryHandle) { + if (!channel) { return; } @@ -542,24 +546,24 @@ static void telemetryTxTask(void *parameters) */ #ifdef PIOS_TELEM_PRIORITY_QUEUE // empty priority queue, non-blocking - while (xQueueReceive(telemetryHandle->priorityQueue, &ev, 0) == pdTRUE) { + while (xQueueReceive(channel->priorityQueue, &ev, 0) == pdTRUE) { // Process event - processObjEvent(telemetryHandle, &ev); + processObjEvent(channel, &ev); } // check regular queue and process update - non-blocking - if (xQueueReceive(telemetryHandle->mainQueue, &ev, 0) == pdTRUE) { + if (xQueueReceive(channel->mainQueue, &ev, 0) == pdTRUE) { // Process event - processObjEvent(telemetryHandle, &ev); + processObjEvent(channel, &ev); // if both queues are empty, wait on priority queue for updates (1 tick) then repeat cycle - } else if (xQueueReceive(telemetryHandle->priorityQueue, &ev, 1) == pdTRUE) { + } else if (xQueueReceive(channel->priorityQueue, &ev, 1) == pdTRUE) { // Process event - processObjEvent(telemetryHandle, &ev); + processObjEvent(channel, &ev); } #else // wait on queue for updates (1 tick) then repeat cycle - if (xQueueReceive(telemetryHandle->mainQueue, &ev, 1) == pdTRUE) { + if (xQueueReceive(channel->mainQueue, &ev, 1) == pdTRUE) { // Process event - processObjEvent(telemetryHandle, &ev); + processObjEvent(channel, &ev); } #endif /* PIOS_TELEM_PRIORITY_QUEUE */ } @@ -571,16 +575,16 @@ static void telemetryTxTask(void *parameters) */ static void telemetryRxTask(void *parameters) { - telemetryContext *telemetryHandle = (telemetryContext *)parameters; + channelContext *channel = (channelContext *)parameters; /* Check for a bad context */ - if (!telemetryHandle) { + if (!channel) { return; } // Task loop while (1) { - uint32_t inputPort = telemetryHandle->telemetryPort(); + uint32_t inputPort = channel->getPort(); if (inputPort) { // Block until data are available @@ -590,7 +594,7 @@ static void telemetryRxTask(void *parameters) bytes_to_process = PIOS_COM_ReceiveBuffer(inputPort, serial_data, sizeof(serial_data), 500); if (bytes_to_process > 0) { for (uint8_t i = 0; i < bytes_to_process; i++) { - UAVTalkProcessInputStream(telemetryHandle->uavTalkCon, serial_data[i]); + UAVTalkProcessInputStream(channel->uavTalkCon, serial_data[i]); } } } else { @@ -604,7 +608,7 @@ static void telemetryRxTask(void *parameters) * Determine the port to be used for communication on the telemetry channel * \return com port number */ -static uint32_t telemPort() +static uint32_t localPort() { return PIOS_COM_TELEM_RF; } @@ -639,9 +643,9 @@ static uint32_t radioPort() * \return -1 on failure * \return number of bytes transmitted on success */ -static int32_t transmitData(uint8_t *data, int32_t length) +static int32_t transmitLocalData(uint8_t *data, int32_t length) { - uint32_t outputPort = telemHandle.telemetryPort(); + uint32_t outputPort = localChannel.getPort(); if (outputPort) { return PIOS_COM_SendBuffer(outputPort, data, length); @@ -660,7 +664,7 @@ static int32_t transmitData(uint8_t *data, int32_t length) */ static int32_t transmitRadioData(uint8_t *data, int32_t length) { - uint32_t outputPort = radioHandle.telemetryPort(); + uint32_t outputPort = radioChannel.getPort(); if (outputPort) { return PIOS_COM_SendBuffer(outputPort, data, length); @@ -678,7 +682,7 @@ static int32_t transmitRadioData(uint8_t *data, int32_t length) * \return -1 Failure */ static int32_t setUpdatePeriod( - telemetryContext *telemetryHandle, + channelContext *channel, UAVObjHandle obj, int32_t updatePeriodMs) { @@ -692,10 +696,10 @@ static int32_t setUpdatePeriod( ev.lowPriority = true; #ifdef PIOS_TELEM_PRIORITY_QUEUE - xQueueHandle targetQueue = UAVObjIsPriority(obj) ? telemetryHandle->priorityQueue : - telemetryHandle->mainQueue; + xQueueHandle targetQueue = UAVObjIsPriority(obj) ? channel->priorityQueue : + channel->mainQueue; #else /* PIOS_TELEM_PRIORITY_QUEUE */ - xQueueHandle targetQueue = telemetryHandle->mainQueue; + xQueueHandle targetQueue = channel->mainQueue; #endif /* PIOS_TELEM_PRIORITY_QUEUE */ ret = EventPeriodicQueueUpdate(&ev, targetQueue, updatePeriodMs); @@ -714,7 +718,7 @@ static int32_t setUpdatePeriod( * \return -1 Failure */ static int32_t setLoggingPeriod( - telemetryContext *telemetryHandle, + channelContext *channel, UAVObjHandle obj, int32_t updatePeriodMs) { @@ -728,10 +732,10 @@ static int32_t setLoggingPeriod( ev.lowPriority = true; #ifdef PIOS_TELEM_PRIORITY_QUEUE - xQueueHandle targetQueue = UAVObjIsPriority(obj) ? telemetryHandle->priorityQueue : - telemetryHandle->mainQueue; + xQueueHandle targetQueue = UAVObjIsPriority(obj) ? channel->priorityQueue : + channel->mainQueue; #else /* PIOS_TELEM_PRIORITY_QUEUE */ - xQueueHandle targetQueue = telemetryHandle->mainQueue; + xQueueHandle targetQueue = channel->mainQueue; #endif /* PIOS_TELEM_PRIORITY_QUEUE */ ret = EventPeriodicQueueUpdate(&ev, targetQueue, updatePeriodMs); @@ -771,8 +775,8 @@ static void updateTelemetryStats() uint32_t timeNow; // Get stats - UAVTalkGetStats(telemHandle.uavTalkCon, &utalkStats, true); - UAVTalkAddStats(radioHandle.uavTalkCon, &utalkStats, true); + UAVTalkGetStats(localChannel.uavTalkCon, &utalkStats, true); + UAVTalkAddStats(radioChannel.uavTalkCon, &utalkStats, true); // Get object data FlightTelemetryStatsGet(&flightStats); @@ -862,9 +866,9 @@ static void updateTelemetryStats() * settings, etc. Thus the HwSettings object which contains the * telemetry port speed is used for now. */ -static void updateSettings(telemetryContext *telemetryHandle) +static void updateSettings(channelContext *channel) { - uint32_t port = telemetryHandle->telemetryPort(); + uint32_t port = channel->getPort(); if (port) { // Retrieve settings From 8bf717fec2356f28718a223852a218a3ecd8cdb3 Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 16 Mar 2015 14:51:04 +0100 Subject: [PATCH 16/44] OP-1777 Changed some text. --- ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui index 2a727171f..87518212b 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui @@ -157,7 +157,7 @@ - Gather and upload usage data: + Contribute usage statistics: From d948b1ca1c4e0b3f1a8c3b26cc1a7c7cae13fcf9 Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 16 Mar 2015 14:51:36 +0100 Subject: [PATCH 17/44] OP-1777 Added caching of collected data hash. --- .../src/plugins/coreplugin/generalsettings.cpp | 12 ++++++++++++ .../src/plugins/coreplugin/generalsettings.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp index 4d5f8d880..5f13242df 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp @@ -167,6 +167,7 @@ void GeneralSettings::readSettings(QSettings *qs) m_useExpertMode = qs->value(QLatin1String("ExpertMode"), m_useExpertMode).toBool(); m_collectUsageData = qs->value(QLatin1String("CollectUsageData"), m_collectUsageData).toBool(); m_showUsageDataDisclaimer = qs->value(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer).toBool(); + m_lastUsageHash = qs->value(QLatin1String("LastUsageHash"), m_lastUsageHash).toString(); qs->endGroup(); } @@ -187,6 +188,7 @@ void GeneralSettings::saveSettings(QSettings *qs) qs->setValue(QLatin1String("ExpertMode"), m_useExpertMode); qs->setValue(QLatin1String("CollectUsageData"), m_collectUsageData); qs->setValue(QLatin1String("ShowUsageDataDisclaimer"), m_showUsageDataDisclaimer); + qs->setValue(QLatin1String("LastUsageHash"), m_lastUsageHash); qs->endGroup(); } @@ -267,6 +269,11 @@ bool GeneralSettings::showUsageDataDisclaimer() const return m_showUsageDataDisclaimer; } +QString GeneralSettings::lastUsageHash() const +{ + return m_lastUsageHash; +} + bool GeneralSettings::useExpertMode() const { return m_useExpertMode; @@ -285,6 +292,11 @@ bool GeneralSettings::setShowUsageDataDisclaimer(bool show) m_showUsageDataDisclaimer = show; } +void GeneralSettings::setLastUsageHash(QString hash) +{ + m_lastUsageHash = hash; +} + void GeneralSettings::slotAutoConnect(int value) { if (value == Qt::Checked) { diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h index 24a6acf14..6fdefb20e 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h @@ -59,11 +59,13 @@ public: bool useUDPMirror() const; bool collectUsageData() const; bool showUsageDataDisclaimer() const; + QString lastUsageHash() const; void readSettings(QSettings *qs); void saveSettings(QSettings *qs); bool useExpertMode() const; bool setCollectUsageData(bool collect); bool setShowUsageDataDisclaimer(bool show); + void setLastUsageHash(QString hash); private slots: void resetInterfaceColor(); @@ -84,6 +86,7 @@ private: bool m_useExpertMode; bool m_collectUsageData; bool m_showUsageDataDisclaimer; + QString m_lastUsageHash; QPointer m_dialog; QList m_codecs; }; From 14f2bb6ce99c9b6763d87ac7d34070eabcaad132 Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 16 Mar 2015 14:53:26 +0100 Subject: [PATCH 18/44] OP-1777 Added caching of collected data hash to avoid sending duplicate redundant data. Changed some text. Changed nag-dialog text to use html for formatting to make it easier to translate and maintain. Removed timestamp from hash. --- .../usagetracker/usagetrackerplugin.cpp | 69 ++++++++++++------- .../plugins/usagetracker/usagetrackerplugin.h | 5 +- 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index 3650826a9..8ef609296 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -38,6 +38,7 @@ #include #include "version_info/version_info.h" #include "coreplugin/icore.h" +#include UsageTrackerPlugin::UsageTrackerPlugin() : m_telemetryManager(NULL) @@ -82,27 +83,27 @@ void UsageTrackerPlugin::onAutopilotConnect() message.addButton(tr("Yes, count me in"), QMessageBox::AcceptRole); message.addButton(tr("No, I will not help"), QMessageBox::RejectRole); message.setText(tr("Openpilot GCS has a function to collect limited anonymous information about " - "the usage of the application itself and the OpenPilot hardware connected to it.\n\n" + "the usage of the application itself and the OpenPilot hardware connected to it.

" "The intention is to not include anything that can be considered sensitive " "or a threat to the users integrity. The collected information will be sent " "using a secure protocol to an OpenPilot web service and stored in a database " - "for later analysis and statistical purposes.\n" + "for later analysis and statistical purposes.
" "No information will be sold or given to any third party. The sole purpose is " "to collect statistics about the usage of our software and hardware to enable us " - "to make things better for you.\n\n" - "The following things are collected:\n" - "- Bootloader version\n" - "- Firmware version, tag and git hash\n" - "- OP Hardware type, revision and mcu serial number\n" - "- Selected configuration parameters\n" - "- GCS version\n" - "- Operating system version and architecture\n" - "- Current local time\n" - "The information is collected only at the time when a board is connecting to GCS.\n\n" + "to make things better for you.

" + "The following things are collected:

    " + "
  • Bootloader version
  • " + "
  • Firmware version, tag and git hash
  • " + "
  • OP Hardware type, revision and mcu serial number
  • " + "
  • Selected configuration parameters
  • " + "
  • GCS version
  • " + "
  • Operating system version and architecture
  • " + "
  • Current local time
" + "The information is collected only at the time when a board is connecting to GCS.

" "It is possible to enable or disable this functionality in the general " - "settings part of the options for the GCS application at any time.\n\n" + "settings part of the options for the GCS application at any time.

" "We need your help, with your feedback we know where to improve things and what " - "platforms are in use. This is a community project that depends on people being involved.\n" + "platforms are in use. This is a community project that depends on people being involved.
" "Thank You for helping us making things better and for supporting OpenPilot!")); QCheckBox *disclaimerCb = new QCheckBox(tr("&Don't show this message again.")); disclaimerCb->setChecked(true); @@ -122,11 +123,6 @@ void UsageTrackerPlugin::onAutopilotConnect() void UsageTrackerPlugin::trackUsage() { - QNetworkAccessManager *networkAccessManager = new QNetworkAccessManager(); - - // This will delete the network access manager instance when we're done - connect(networkAccessManager, SIGNAL(finished(QNetworkReply *)), networkAccessManager, SLOT(deleteLater())); - QMap parameters; collectUsageParameters(parameters); @@ -138,11 +134,24 @@ void UsageTrackerPlugin::trackUsage() } // Add checksum - query.addQueryItem("hash", getQueryHash(query.toString())); + QString hash = getQueryHash(query.toString()); - QUrl url("https://www.openpilot.org/opver?" + query.toString(QUrl::FullyEncoded)); - qDebug() << "Sending usage tracking as:" << url.toEncoded(QUrl::FullyEncoded); - networkAccessManager->get(QNetworkRequest(QUrl(url.toEncoded(QUrl::FullyEncoded)))); + if (shouldSend(hash)) { + query.addQueryItem("hash", hash); + + // Add local timestamp + query.addQueryItem("localtime", QDateTime::currentDateTime().toString(Qt::ISODate)); + + QUrl url("https://www.openpilot.org/opver?" + query.toString(QUrl::FullyEncoded)); + + QNetworkAccessManager *networkAccessManager = new QNetworkAccessManager(); + + // This will delete the network access manager instance when we're done + connect(networkAccessManager, SIGNAL(finished(QNetworkReply *)), networkAccessManager, SLOT(deleteLater())); + + qDebug() << "Sending usage tracking as:" << url.toEncoded(QUrl::FullyEncoded); + networkAccessManager->get(QNetworkRequest(QUrl(url.toEncoded(QUrl::FullyEncoded)))); + } } void UsageTrackerPlugin::collectUsageParameters(QMap ¶meters) @@ -163,7 +172,6 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete parameters["os_version"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); parameters["os_threads"] = QString::number(QThread::idealThreadCount()); parameters["gcs_version"] = VersionInfo::revision(); - parameters["localtime"] = QDateTime::currentDateTime().toString(Qt::ISODate); // Configuration parameters ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); @@ -213,3 +221,16 @@ QString UsageTrackerPlugin::getQueryHash(QString source) const source += "OpenPilot Fuck Yeah!"; return QString(QCryptographicHash::hash(QByteArray(source.toStdString().c_str()), QCryptographicHash::Md5).toHex()); } + +bool UsageTrackerPlugin::shouldSend(const QString &hash) +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + Core::Internal::GeneralSettings *settings = pm->getObject(); + + if (settings->lastUsageHash() == hash) { + return false; + } else { + settings->setLastUsageHash(hash); + return true; + } +} diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h index 1767cf274..8cd8504ff 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h @@ -28,7 +28,9 @@ #define USAGETRACKERPLUGIN_H #include -#include + +class TelemetryManager; +class UAVObjectManager; class UsageTrackerPlugin : public ExtensionSystem::IPlugin { Q_OBJECT @@ -50,6 +52,7 @@ private: TelemetryManager *m_telemetryManager; QString getUAVFieldValue(UAVObjectManager *objManager, QString objectName, QString fieldName, int index = 0) const; QString getQueryHash(QString source) const; + bool shouldSend(const QString &hash); }; #endif // USAGETRACKERPLUGIN_H From 6a89427aa84291bfadf4e79eb5b0098572bd447a Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 16 Mar 2015 20:38:56 +0100 Subject: [PATCH 19/44] OP-1777 Added handling of network issues. Changed local time to timezone. Re-factored some functions. --- .../usagetracker/usagetrackerplugin.cpp | 30 +++++++++++++------ .../plugins/usagetracker/usagetrackerplugin.h | 5 ++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index 8ef609296..ec670480d 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -29,13 +29,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include "version_info/version_info.h" #include "coreplugin/icore.h" #include @@ -72,8 +72,7 @@ void UsageTrackerPlugin::shutdown() void UsageTrackerPlugin::onAutopilotConnect() { - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); + Core::Internal::GeneralSettings *settings = getGeneralSettings(); if (settings->collectUsageData()) { if (settings->showUsageDataDisclaimer()) { @@ -139,14 +138,12 @@ void UsageTrackerPlugin::trackUsage() if (shouldSend(hash)) { query.addQueryItem("hash", hash); - // Add local timestamp - query.addQueryItem("localtime", QDateTime::currentDateTime().toString(Qt::ISODate)); - QUrl url("https://www.openpilot.org/opver?" + query.toString(QUrl::FullyEncoded)); QNetworkAccessManager *networkAccessManager = new QNetworkAccessManager(); // This will delete the network access manager instance when we're done + connect(networkAccessManager, SIGNAL(finished(QNetworkReply *)), this, SLOT(onFinished(QNetworkReply *))); connect(networkAccessManager, SIGNAL(finished(QNetworkReply *)), networkAccessManager, SLOT(deleteLater())); qDebug() << "Sending usage tracking as:" << url.toEncoded(QUrl::FullyEncoded); @@ -171,6 +168,7 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete parameters["fw_hash"] = devDesc.gitHash; parameters["os_version"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); parameters["os_threads"] = QString::number(QThread::idealThreadCount()); + parameters["os_timezone"] = QTimeZone::systemTimeZoneId(); parameters["gcs_version"] = VersionInfo::revision(); // Configuration parameters @@ -203,6 +201,16 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete } } +void UsageTrackerPlugin::onFinished(QNetworkReply *reply) +{ + if (reply->error() == QNetworkReply::NoError) { + getGeneralSettings()->setLastUsageHash(m_lastHash); + qDebug() << "Updated last usage hash to:" << m_lastHash; + } else { + qDebug() << "Usage tracking failed with:" << reply->errorString(); + } +} + QString UsageTrackerPlugin::getUAVFieldValue(UAVObjectManager *objManager, QString objectName, QString fieldName, int index) const { UAVObject *object = objManager->getObject(objectName); @@ -222,15 +230,19 @@ QString UsageTrackerPlugin::getQueryHash(QString source) const return QString(QCryptographicHash::hash(QByteArray(source.toStdString().c_str()), QCryptographicHash::Md5).toHex()); } -bool UsageTrackerPlugin::shouldSend(const QString &hash) +Core::Internal::GeneralSettings * UsageTrackerPlugin::getGeneralSettings() const { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); Core::Internal::GeneralSettings *settings = pm->getObject(); + return settings; +} - if (settings->lastUsageHash() == hash) { +bool UsageTrackerPlugin::shouldSend(const QString &hash) +{ + if (getGeneralSettings()->lastUsageHash() == hash) { return false; } else { - settings->setLastUsageHash(hash); + m_lastHash = hash; return true; } } diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h index 8cd8504ff..5a3394b47 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h @@ -28,9 +28,11 @@ #define USAGETRACKERPLUGIN_H #include +#include class TelemetryManager; class UAVObjectManager; +class QNetworkReply; class UsageTrackerPlugin : public ExtensionSystem::IPlugin { Q_OBJECT @@ -47,11 +49,14 @@ private slots: void onAutopilotConnect(); void trackUsage(); void collectUsageParameters(QMap ¶meters); + void onFinished(QNetworkReply *reply); private: TelemetryManager *m_telemetryManager; + QString m_lastHash; QString getUAVFieldValue(UAVObjectManager *objManager, QString objectName, QString fieldName, int index = 0) const; QString getQueryHash(QString source) const; + Core::Internal::GeneralSettings * getGeneralSettings() const; bool shouldSend(const QString &hash); }; From e4e3125e7264445936dd78f2f326f6ff99f689e6 Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 16 Mar 2015 20:41:38 +0100 Subject: [PATCH 20/44] OP-1777 Uncrustify --- .../src/plugins/usagetracker/usagetrackerplugin.cpp | 11 ++++++----- .../src/plugins/usagetracker/usagetrackerplugin.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index ec670480d..f38e34ee3 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -168,7 +168,7 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete parameters["fw_hash"] = devDesc.gitHash; parameters["os_version"] = QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture(); parameters["os_threads"] = QString::number(QThread::idealThreadCount()); - parameters["os_timezone"] = QTimeZone::systemTimeZoneId(); + parameters["os_timezone"] = QTimeZone::systemTimeZoneId(); parameters["gcs_version"] = VersionInfo::revision(); // Configuration parameters @@ -195,9 +195,9 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete parameters["conf_vport"] = getUAVFieldValue(objManager, "HwSettings", "USB_VCPPort"); parameters["conf_rotation"] = QString("%1:%2:%3") - .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 0)) - .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 1)) - .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 2)); + .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 0)) + .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 1)) + .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 2)); } } @@ -230,10 +230,11 @@ QString UsageTrackerPlugin::getQueryHash(QString source) const return QString(QCryptographicHash::hash(QByteArray(source.toStdString().c_str()), QCryptographicHash::Md5).toHex()); } -Core::Internal::GeneralSettings * UsageTrackerPlugin::getGeneralSettings() const +Core::Internal::GeneralSettings *UsageTrackerPlugin::getGeneralSettings() const { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); Core::Internal::GeneralSettings *settings = pm->getObject(); + return settings; } diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h index 5a3394b47..3f1bc9b84 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.h @@ -56,7 +56,7 @@ private: QString m_lastHash; QString getUAVFieldValue(UAVObjectManager *objManager, QString objectName, QString fieldName, int index = 0) const; QString getQueryHash(QString source) const; - Core::Internal::GeneralSettings * getGeneralSettings() const; + Core::Internal::GeneralSettings *getGeneralSettings() const; bool shouldSend(const QString &hash); }; From dda065db644ed6b65bba666993388c73221ab76c Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 16 Mar 2015 21:37:46 +0100 Subject: [PATCH 21/44] OP-1777 Attempting to fix build issues in Win and Mac builds. --- ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro b/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro index 1eca75047..b457f1454 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro @@ -12,3 +12,4 @@ HEADERS += usagetrackerplugin.h SOURCES += usagetrackerplugin.cpp OTHER_FILES += usagetracker.pluginspec +QT += network From 4c58675fc3a51d8c5fb44a330d98b5644d791d6b Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 16 Mar 2015 21:43:06 +0100 Subject: [PATCH 22/44] OP-1777 Adding dependecy to VersionInfo lib. --- ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro b/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro index b457f1454..13181f8f9 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro @@ -3,6 +3,7 @@ TEMPLATE = lib TARGET = UsageTracker include(../../openpilotgcsplugin.pri) +include(../../libs/version_info/version_info.pri) include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/uavobjects/uavobjects.pri) include(../../plugins/uavobjectutil/uavobjectutil.pri) From ba217a3d7d6674579a312a584b28bf5e51234971 Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Tue, 17 Mar 2015 20:52:08 +0000 Subject: [PATCH 23/44] OP-1289 Revise naming of mainQueue to queue As per review comments +review OPReview-985 --- flight/modules/Telemetry/telemetry.c | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index 6f6a4e0d9..ee7e53cda 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -100,7 +100,7 @@ typedef struct { // Determine port on which to communicate telemetry information uint32_t (*getPort)(); // Main telemetry queue - xQueueHandle mainQueue; + xQueueHandle queue; #ifdef PIOS_TELEM_PRIORITY_QUEUE // Priority telemetry queue xQueueHandle priorityQueue; @@ -165,8 +165,8 @@ int32_t TelemetryStart(void) GCSTelemetryStatsConnectQueue(localChannel.priorityQueue); GCSTelemetryStatsConnectQueue(radioChannel.priorityQueue); #else /* PIOS_TELEM_PRIORITY_QUEUE */ - GCSTelemetryStatsConnectQueue(localChannel.mainQueue); - GCSTelemetryStatsConnectQueue(radioChannel.mainQueue); + GCSTelemetryStatsConnectQueue(localChannel.queue); + GCSTelemetryStatsConnectQueue(radioChannel.queue); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ // Start telemetry tasks @@ -221,9 +221,9 @@ int32_t TelemetryInitialize(void) timeOfLastObjectUpdate = 0; // Create object queues - localChannel.mainQueue = xQueueCreate(MAX_QUEUE_SIZE, + localChannel.queue = xQueueCreate(MAX_QUEUE_SIZE, sizeof(UAVObjEvent)); - radioChannel.mainQueue = xQueueCreate(MAX_QUEUE_SIZE, + radioChannel.queue = xQueueCreate(MAX_QUEUE_SIZE, sizeof(UAVObjEvent)); #if defined(PIOS_TELEM_PRIORITY_QUEUE) localChannel.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, @@ -259,10 +259,10 @@ int32_t TelemetryInitialize(void) STATS_UPDATE_PERIOD_MS); #else /* PIOS_TELEM_PRIORITY_QUEUE */ EventPeriodicQueueCreate(&ev, - localChannel.mainQueue, + localChannel.queue, STATS_UPDATE_PERIOD_MS); EventPeriodicQueueCreate(&ev, - radioChannel.mainQueue, + radioChannel.queue, STATS_UPDATE_PERIOD_MS); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ @@ -283,7 +283,7 @@ static void registerLocalObject(UAVObjHandle obj) #ifdef PIOS_TELEM_PRIORITY_QUEUE UAVObjConnectQueue(obj, localChannel.priorityQueue, EV_MASK_ALL_UPDATES); #else /* PIOS_TELEM_PRIORITY_QUEUE */ - UAVObjConnectQueue(obj, localChannel.mainQueue, EV_MASK_ALL_UPDATES); + UAVObjConnectQueue(obj, localChannel.queue, EV_MASK_ALL_UPDATES); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ } else { // Setup object for periodic updates @@ -301,7 +301,7 @@ static void registerRadioObject(UAVObjHandle obj) #ifdef PIOS_TELEM_PRIORITY_QUEUE UAVObjConnectQueue(obj, radioChannel.priorityQueue, EV_MASK_ALL_UPDATES); #else /* PIOS_TELEM_PRIORITY_QUEUE */ - UAVObjConnectQueue(obj, radioChannel.mainQueue, EV_MASK_ALL_UPDATES); + UAVObjConnectQueue(obj, radioChannel.queue, EV_MASK_ALL_UPDATES); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ } else { // Setup object for periodic updates @@ -419,7 +419,7 @@ static void updateObject( UAVObjConnectQueue(obj, channel->priorityQueue, eventMask); } else #endif /* PIOS_TELEM_PRIORITY_QUEUE */ - UAVObjConnectQueue(obj, channel->mainQueue, eventMask); + UAVObjConnectQueue(obj, channel->queue, eventMask); } @@ -551,7 +551,7 @@ static void telemetryTxTask(void *parameters) processObjEvent(channel, &ev); } // check regular queue and process update - non-blocking - if (xQueueReceive(channel->mainQueue, &ev, 0) == pdTRUE) { + if (xQueueReceive(channel->queue, &ev, 0) == pdTRUE) { // Process event processObjEvent(channel, &ev); // if both queues are empty, wait on priority queue for updates (1 tick) then repeat cycle @@ -561,7 +561,7 @@ static void telemetryTxTask(void *parameters) } #else // wait on queue for updates (1 tick) then repeat cycle - if (xQueueReceive(channel->mainQueue, &ev, 1) == pdTRUE) { + if (xQueueReceive(channel->queue, &ev, 1) == pdTRUE) { // Process event processObjEvent(channel, &ev); } @@ -697,9 +697,9 @@ static int32_t setUpdatePeriod( #ifdef PIOS_TELEM_PRIORITY_QUEUE xQueueHandle targetQueue = UAVObjIsPriority(obj) ? channel->priorityQueue : - channel->mainQueue; + channel->queue; #else /* PIOS_TELEM_PRIORITY_QUEUE */ - xQueueHandle targetQueue = channel->mainQueue; + xQueueHandle targetQueue = channel->queue; #endif /* PIOS_TELEM_PRIORITY_QUEUE */ ret = EventPeriodicQueueUpdate(&ev, targetQueue, updatePeriodMs); @@ -733,9 +733,9 @@ static int32_t setLoggingPeriod( #ifdef PIOS_TELEM_PRIORITY_QUEUE xQueueHandle targetQueue = UAVObjIsPriority(obj) ? channel->priorityQueue : - channel->mainQueue; + channel->queue; #else /* PIOS_TELEM_PRIORITY_QUEUE */ - xQueueHandle targetQueue = channel->mainQueue; + xQueueHandle targetQueue = channel->queue; #endif /* PIOS_TELEM_PRIORITY_QUEUE */ ret = EventPeriodicQueueUpdate(&ev, targetQueue, updatePeriodMs); From 52984119f0a0afc5702918f997826076d7d3884a Mon Sep 17 00:00:00 2001 From: m_thread Date: Tue, 17 Mar 2015 22:18:14 +0100 Subject: [PATCH 24/44] OP-1777 Moved Qt include statement. --- ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro b/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro index 13181f8f9..e7a7c91be 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetracker.pro @@ -1,6 +1,7 @@ TEMPLATE = lib TARGET = UsageTracker +QT += network include(../../openpilotgcsplugin.pri) include(../../libs/version_info/version_info.pri) @@ -13,4 +14,3 @@ HEADERS += usagetrackerplugin.h SOURCES += usagetrackerplugin.cpp OTHER_FILES += usagetracker.pluginspec -QT += network From deeb7c350255a1e94060f4d1f816a8b118e57be1 Mon Sep 17 00:00:00 2001 From: m_thread Date: Sat, 21 Mar 2015 10:14:32 +0100 Subject: [PATCH 25/44] OP-1777 Added some more information from configuration to uploaded data. --- .../usagetracker/usagetrackerplugin.cpp | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp index f38e34ee3..10a1cb294 100644 --- a/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp +++ b/ground/openpilotgcs/src/plugins/usagetracker/usagetrackerplugin.cpp @@ -194,10 +194,41 @@ void UsageTrackerPlugin::collectUsageParameters(QMap ¶mete parameters["conf_uport"] = getUAVFieldValue(objManager, "HwSettings", "USB_HIDPort"); parameters["conf_vport"] = getUAVFieldValue(objManager, "HwSettings", "USB_VCPPort"); - parameters["conf_rotation"] = QString("%1:%2:%3") + parameters["conf_rotation"] = QString("[%1:%2:%3]") .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 0)) .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 1)) .arg(getUAVFieldValue(objManager, "AttitudeSettings", "BoardRotation", 2)); + parameters["conf_pidr"] = QString("[%1:%2:%3:%4][%5:%6:%7:%8][%9:%10:%11:%12]") + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollRatePID", 0)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollRatePID", 1)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollRatePID", 2)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollRatePID", 3)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchRatePID", 0)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchRatePID", 1)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchRatePID", 2)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchRatePID", 3)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawRatePID", 0)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawRatePID", 1)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawRatePID", 2)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawRatePID", 3)); + parameters["conf_pia"] = QString("[%1:%2:%3][%4:%5:%6][%7:%8:%9]") + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollPI", 0)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollPI", 1)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "RollPI", 2)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchPI", 0)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchPI", 1)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "PitchPI", 2)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawPI", 0)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawPI", 1)) + .arg(getUAVFieldValue(objManager, "StabilizationSettingsBank1", "YawPI", 2)); + + parameters["conf_tps"] = getUAVFieldValue(objManager, "StabilizationSettingsBank1", "EnableThrustPIDScaling"); + parameters["conf_piro"] = getUAVFieldValue(objManager, "StabilizationSettingsBank1", "EnablePiroComp"); + + parameters["conf_fmcount"] = getUAVFieldValue(objManager, "ManualControlSettings", "FlightModeNumber"); + parameters["conf_fmodes"] = QString("[%1:%2:%3]").arg(getUAVFieldValue(objManager, "FlightModeSettings", "FlightModePosition", 0)) + .arg(getUAVFieldValue(objManager, "FlightModeSettings", "FlightModePosition", 1)) + .arg(getUAVFieldValue(objManager, "FlightModeSettings", "FlightModePosition", 2)); } } From 428bba0c0960ad0c686db149c4df2c81a25a7499 Mon Sep 17 00:00:00 2001 From: James Duley Date: Wed, 18 Mar 2015 12:56:57 +1300 Subject: [PATCH 26/44] OP-1792: make firmware_info.c depend on uavobjectdefition instead of FORCE so it isn't always updated --- make/firmware-defs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/firmware-defs.mk b/make/firmware-defs.mk index 5f1ed36ee..d184c0b05 100644 --- a/make/firmware-defs.mk +++ b/make/firmware-defs.mk @@ -136,7 +136,7 @@ endef define OPFW_TEMPLATE FORCE: -$(1).firmware_info.c: $(1) $(ROOT_DIR)/flight/templates/firmware_info.c.template FORCE +$(1).firmware_info.c: $(1) $(ROOT_DIR)/flight/templates/firmware_info.c.template $(ROOT_DIR)/shared/uavobjectdefinition @$(ECHO) $(MSG_FWINFO) $$(call toprel, $$@) $(V1) $(VERSION_INFO) \ --template=$(ROOT_DIR)/flight/templates/firmware_info.c.template \ From 4f50be6a4431811456298a66882f53bbc98bb16f Mon Sep 17 00:00:00 2001 From: James Duley Date: Wed, 18 Mar 2015 12:58:06 +1300 Subject: [PATCH 27/44] OP-1792 Makefile: remove old Android stuff --- Makefile | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) diff --git a/Makefile b/Makefile index 97ff2d923..f387d96d5 100644 --- a/Makefile +++ b/Makefile @@ -531,49 +531,6 @@ uploader_clean: $(V1) [ ! -d "$(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)" ] || $(RM) -r "$(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)" -################################ -# -# Android GCS related components -# -################################ - -# Build the output directory for the Android GCS build -ANDROIDGCS_OUT_DIR := $(BUILD_DIR)/androidgcs -$(ANDROIDGCS_OUT_DIR): - $(V1) $(MKDIR) -p $@ - -# Build the asset directory for the android assets -ANDROIDGCS_ASSETS_DIR := $(ANDROIDGCS_OUT_DIR)/assets -$(ANDROIDGCS_ASSETS_DIR)/uavos: - $(V1) $(MKDIR) -p $@ - -ifeq ($(V), 1) - ANT_QUIET := - ANDROID_SILENT := -else - ANT_QUIET := -q - ANDROID_SILENT := -s -endif - -.PHONY: androidgcs -androidgcs: uavo-collections_java - $(V0) @$(ECHO) " ANDROID $(call toprel, $(ANDROIDGCS_OUT_DIR))" - $(V1) $(MKDIR) -p $(ANDROIDGCS_OUT_DIR) - $(V1) $(ANDROID) $(ANDROID_SILENT) update project \ - --target "Google Inc.:Google APIs:$(GOOGLE_API_VERSION)" \ - --name androidgcs \ - --path ./androidgcs - $(V1) $(ANT) -f ./androidgcs/build.xml \ - $(ANT_QUIET) \ - -Dout.dir="../$(call toprel, $(ANDROIDGCS_OUT_DIR)/bin)" \ - -Dgen.absolute.dir="$(ANDROIDGCS_OUT_DIR)/gen" \ - $(ANDROIDGCS_BUILD_CONF) - -.PHONY: androidgcs_clean -androidgcs_clean: - @$(ECHO) " CLEAN $(call toprel, $(ANDROIDGCS_OUT_DIR))" - $(V1) [ ! -d "$(ANDROIDGCS_OUT_DIR)" ] || $(RM) -r "$(ANDROIDGCS_OUT_DIR)" - # We want to take snapshots of the UAVOs at each point that they change # to allow the GCS to be compatible with as many versions as possible. # We always include a pseudo collection called "srctree" which represents @@ -928,7 +885,6 @@ help: @$(ECHO) " openocd_install - Install the OpenOCD JTAG daemon" @$(ECHO) " stm32flash_install - Install the stm32flash tool for unbricking F1-based boards" @$(ECHO) " dfuutil_install - Install the dfu-util tool for unbricking F4-based boards" - @$(ECHO) " android_sdk_install - Install the Android SDK tools" @$(ECHO) " Install all available tools:" @$(ECHO) " all_sdk_install - Install all of above (platform-dependent)" @$(ECHO) " build_sdk_install - Install only essential for build tools (platform-dependent)" @@ -1014,12 +970,6 @@ help: @$(ECHO) " Supported build configurations: GCS_BUILD_CONF=debug|release (default is $(GCS_BUILD_CONF))" @$(ECHO) @$(ECHO) - @$(ECHO) " [AndroidGCS]" - @$(ECHO) " androidgcs - Build the Android Ground Control System (GCS) application" - @$(ECHO) " androidgcs_install - Use ADB to install the Android GCS application" - @$(ECHO) " androidgcs_run - Run the Android GCS application" - @$(ECHO) " androidgcs_clean - Remove the Android GCS application" - @$(ECHO) @$(ECHO) " [UAVObjects]" @$(ECHO) " uavobjects - Generate source files from the UAVObject definition XML files" @$(ECHO) " uavobjects_test - Parse xml-files - check for valid, duplicate ObjId's, ..." From 3a08642b4080575e22bf0e01dfb4e56eba83c062 Mon Sep 17 00:00:00 2001 From: James Duley Date: Wed, 25 Mar 2015 09:27:00 +1300 Subject: [PATCH 28/44] OP-1792 Makefile tidy: Fix up the 'copydata.pro's to depend on FORCE, not be FORCE, and be aux template, not subdirs template. --- ground/openpilotgcs/copydata.pro | 5 ++-- ground/openpilotgcs/share/copydata.pro | 26 +++++++++++++++++++ ground/openpilotgcs/share/share.pro | 25 ++---------------- .../src/libs/sdlgamepad/copydata.pro | 6 ++--- .../src/plugins/hitl/aerosimrc/src/plugin.pro | 3 ++- .../uavobject-synthetics.pro | 5 ++-- 6 files changed, 38 insertions(+), 32 deletions(-) create mode 100644 ground/openpilotgcs/share/copydata.pro diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 3ececc457..bf9d7b4d7 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -1,6 +1,6 @@ include(openpilotgcs.pri) -TEMPLATE = subdirs +TEMPLATE = aux # Copy Qt runtime libraries into the build directory (to run or package) equals(copyqt, 1) { @@ -26,8 +26,9 @@ equals(copyqt, 1) { data_copy.commands += $(COPY_DIR) $$targetPath(\"$$[QT_INSTALL_QML]/$$dir\") $$targetPath(\"$$GCS_QT_QML_PATH/$$dir\") $$addNewline() } - data_copy.target = FORCE + data_copy.depends = FORCE QMAKE_EXTRA_TARGETS += data_copy + PRE_TARGETDEPS += data_copy linux { diff --git a/ground/openpilotgcs/share/copydata.pro b/ground/openpilotgcs/share/copydata.pro new file mode 100644 index 000000000..2b3a89b6e --- /dev/null +++ b/ground/openpilotgcs/share/copydata.pro @@ -0,0 +1,26 @@ +include(../openpilotgcs.pri) + +TEMPLATE = aux + +DATACOLLECTIONS = cloudconfig default_configurations dials models pfd sounds diagrams mapicons stylesheets + +equals(copydata, 1) { + for(dir, DATACOLLECTIONS) { + exists($$GCS_SOURCE_TREE/share/openpilotgcs/$$dir) { + # Qt make macros (CHK_DIR_EXISTS, COPY_DIR, etc) have different syntax. They cannot be used + # reliably to copy subdirectories in two different Windows environments (bash and cmd/QtCreator). + # So undocumented QMAKE_SH variable is used to find out the real environment. + !isEmpty(QMAKE_SH) { + # sh environment (including Windows bash) + data_copy.commands += $(MKDIR) $$targetPath(\"$$GCS_DATA_PATH/$$dir\") $$addNewline() + data_copy.commands += $(COPY_DIR) $$targetPath(\"$$GCS_SOURCE_TREE/share/openpilotgcs/$$dir\") $$targetPath(\"$$GCS_DATA_PATH/\") $$addNewline() + } else { + # native Windows cmd environment + data_copy.commands += $(COPY_DIR) $$targetPath(\"$$GCS_SOURCE_TREE/share/openpilotgcs/$$dir\") $$targetPath(\"$$GCS_DATA_PATH/$$dir\") $$addNewline() + } + } + } + data_copy.depends = FORCE + QMAKE_EXTRA_TARGETS += data_copy + PRE_TARGETDEPS += data_copy +} diff --git a/ground/openpilotgcs/share/share.pro b/ground/openpilotgcs/share/share.pro index 7a4fe575a..c4d845b95 100644 --- a/ground/openpilotgcs/share/share.pro +++ b/ground/openpilotgcs/share/share.pro @@ -1,26 +1,5 @@ -include(../openpilotgcs.pri) - TEMPLATE = subdirs -SUBDIRS = openpilotgcs/translations -DATACOLLECTIONS = cloudconfig default_configurations dials models pfd sounds diagrams mapicons stylesheets +SUBDIRS = openpilotgcs/translations copydata -equals(copydata, 1) { - for(dir, DATACOLLECTIONS) { - exists($$GCS_SOURCE_TREE/share/openpilotgcs/$$dir) { - # Qt make macros (CHK_DIR_EXISTS, COPY_DIR, etc) have different syntax. They cannot be used - # reliably to copy subdirectories in two different Windows environments (bash and cmd/QtCreator). - # So undocumented QMAKE_SH variable is used to find out the real environment. - !isEmpty(QMAKE_SH) { - # sh environment (including Windows bash) - data_copy.commands += $(MKDIR) $$targetPath(\"$$GCS_DATA_PATH/$$dir\") $$addNewline() - data_copy.commands += $(COPY_DIR) $$targetPath(\"$$GCS_SOURCE_TREE/share/openpilotgcs/$$dir\") $$targetPath(\"$$GCS_DATA_PATH/\") $$addNewline() - } else { - # native Windows cmd environment - data_copy.commands += $(COPY_DIR) $$targetPath(\"$$GCS_SOURCE_TREE/share/openpilotgcs/$$dir\") $$targetPath(\"$$GCS_DATA_PATH/$$dir\") $$addNewline() - } - } - } - data_copy.target = FORCE - QMAKE_EXTRA_TARGETS += data_copy -} +copydata.file = copydata.pro diff --git a/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro b/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro index 4fa7cb219..91cc5292c 100644 --- a/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro +++ b/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro @@ -8,11 +8,9 @@ equals(copydata, 1) { data_copy.commands += $(COPY_FILE) $$targetPath(\"$${SDL_DIR}/bin/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() } - # add make target - POST_TARGETDEPS += copydata - - data_copy.target = copydata + data_copy.depends = FORCE QMAKE_EXTRA_TARGETS += data_copy + PRE_TARGETDEPS += data_copy } } diff --git a/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro b/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro index dab7ba70a..dc809e67d 100644 --- a/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro +++ b/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro @@ -65,7 +65,8 @@ equals(copydata, 1) { # data_copy.commands += $(COPY_FILE) $$targetPath(\"$$(QTMINGW)/$$dll\") $$targetPath(\"$$SIM_DIR/$$dll\") $$addNewline() #} - data_copy.target = FORCE + data_copy.depends = FORCE QMAKE_EXTRA_TARGETS += data_copy + PRE_TARGETDEPS += data_copy } } diff --git a/ground/uavobject-synthetics/uavobject-synthetics.pro b/ground/uavobject-synthetics/uavobject-synthetics.pro index 1f974ae80..85e53d139 100644 --- a/ground/uavobject-synthetics/uavobject-synthetics.pro +++ b/ground/uavobject-synthetics/uavobject-synthetics.pro @@ -3,7 +3,7 @@ # Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org # -TEMPLATE = subdirs +TEMPLATE = aux # Some handy defines defineReplace(targetPath) { @@ -64,5 +64,6 @@ win32 { uavobjects.commands += -spec $$SPEC CONFIG+=$${BUILD_CONFIG} -r $$addNewline() } -uavobjects.target = FORCE +uavobjects.depends = FORCE QMAKE_EXTRA_TARGETS += uavobjects +PRE_TARGETDEPS += uavobjects From 5b76f4f96b2263cfe29c2877d691c4b81066c863 Mon Sep 17 00:00:00 2001 From: samguns Date: Tue, 31 Mar 2015 22:54:25 +0800 Subject: [PATCH 29/44] OP-1808 1.Make flight mode stick identification to be optional. 2. Refine some code. --- .../src/plugins/config/configinputwidget.cpp | 54 ++++++++++++------- .../src/plugins/config/configinputwidget.h | 12 +++-- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 9a8a99f22..4d080406c 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -416,18 +416,18 @@ void ConfigInputWidget::goToWizard() // chooses a different TX type (which could otherwise result in // unexpected TX channels being enabled) manualSettingsData = manualSettingsObj->getData(); - previousManualSettingsData = manualSettingsData; + memento.manualSettingsData = manualSettingsData; flightModeSettingsData = flightModeSettingsObj->getData(); - previousFlightModeSettingsData = flightModeSettingsData; + memento.flightModeSettingsData = flightModeSettingsData; flightModeSettingsData.Arming = FlightModeSettings::ARMING_ALWAYSDISARMED; flightModeSettingsObj->setData(flightModeSettingsData); // Stash actuatorSettings actuatorSettingsData = actuatorSettingsObj->getData(); - previousActuatorSettingsData = actuatorSettingsData; + memento.actuatorSettingsData = actuatorSettingsData; // Stash systemSettings systemSettingsData = systemSettingsObj->getData(); - previousSystemSettingsData = systemSettingsData; + memento.systemSettingsData = systemSettingsData; // Now reset channel and actuator settings (disable outputs) resetChannelSettings(); @@ -469,10 +469,10 @@ void ConfigInputWidget::wzCancel() ui->stackedWidget->setCurrentIndex(0); // Load settings back from beginning of wizard - manualSettingsObj->setData(previousManualSettingsData); - flightModeSettingsObj->setData(previousFlightModeSettingsData); - actuatorSettingsObj->setData(previousActuatorSettingsData); - systemSettingsObj->setData(previousSystemSettingsData); + manualSettingsObj->setData(memento.manualSettingsData); + flightModeSettingsObj->setData(memento.flightModeSettingsData); + actuatorSettingsObj->setData(memento.actuatorSettingsData); + systemSettingsObj->setData(memento.systemSettingsData); } void ConfigInputWidget::registerControlActivity() @@ -555,7 +555,7 @@ void ConfigInputWidget::wzNext() restoreMdata(); // Load actuator settings back from beginning of wizard - actuatorSettingsObj->setData(previousActuatorSettingsData); + actuatorSettingsObj->setData(memento.actuatorSettingsData); // Force flight mode neutral to middle and Throttle neutral at 4% adjustSpecialNeutrals(); @@ -802,6 +802,12 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step) disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(identifyControls())); wizardUi->wzNext->setEnabled(true); setTxMovement(nothing); + /* If flight mode stick isn't identified, force flight mode number to be 1 */ + manualSettingsData = manualSettingsObj->getData(); + if (manualSettingsData.ChannelGroups[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE] == + ManualControlSettings::CHANNELGROUPS_NONE) { + forceOneFlightMode(); + } break; case wizardIdentifyCenter: manualCommandData = manualCommandObj->getData(); @@ -882,21 +888,32 @@ void ConfigInputWidget::restoreMdata() */ void ConfigInputWidget::setChannel(int newChan) { + bool canBeSkipped(false); + if (newChan == ManualControlSettings::CHANNELGROUPS_COLLECTIVE) { - wizardUi->identifyStickInstructions->setText(QString(tr("Please enable throttle hold mode.\n\nMove the Collective Pitch stick."))); + wizardUi->identifyStickInstructions->setText(QString(tr("

Please enable throttle hold mode.

" + "

Move the Collective Pitch stick.

"))); } else if (newChan == ManualControlSettings::CHANNELGROUPS_FLIGHTMODE) { - wizardUi->identifyStickInstructions->setText(QString(tr("Please toggle the Flight Mode switch.\n\nFor switches you may have to repeat this rapidly."))); + wizardUi->identifyStickInstructions->setText(QString(tr("

Please toggle the Flight Mode switch.

" + "

For switches you may have to repeat this rapidly.

" + "

Alternatively, you can click Next to skip this channel, but you will get only ONE Flight Mode.

"))); + canBeSkipped = true; } else if ((transmitterType == heli) && (newChan == ManualControlSettings::CHANNELGROUPS_THROTTLE)) { - wizardUi->identifyStickInstructions->setText(QString(tr("Please disable throttle hold mode.\n\nMove the Throttle stick."))); + wizardUi->identifyStickInstructions->setText(QString(tr("

Please disable throttle hold mode.

" + "

Move the Throttle stick.

"))); } else { - wizardUi->identifyStickInstructions->setText(QString(tr("Please move each control one at a time according to the instructions and picture below.\n\n" - "Move the %1 stick.")).arg(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan))); + wizardUi->identifyStickInstructions->setText(QString(tr("

Please move each control one at a time according to the instructions and picture below.

" + "

Move the %1 stick.

")).arg(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan))); } if (manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan).contains("Accessory")) { + wizardUi->identifyStickInstructions->setText(wizardUi->identifyStickInstructions->text() + tr("

Alternatively, click Next to skip this channel.

")); + canBeSkipped = true; + } + + if (true == canBeSkipped) { wizardUi->wzNext->setEnabled(true); wizardUi->wzNext->setText(tr("Next / Skip")); - wizardUi->identifyStickInstructions->setText(wizardUi->identifyStickInstructions->text() + tr(" Alternatively, click Next to skip this channel.")); } else { wizardUi->wzNext->setEnabled(false); } @@ -1674,7 +1691,7 @@ void ConfigInputWidget::simpleCalibration(bool enable) // Stash actuatorSettings actuatorSettingsData = actuatorSettingsObj->getData(); - previousActuatorSettingsData = actuatorSettingsData; + memento.actuatorSettingsData = actuatorSettingsData; // Disable all actuators resetActuatorSettings(); @@ -1720,7 +1737,7 @@ void ConfigInputWidget::simpleCalibration(bool enable) manualSettingsObj->setData(manualSettingsData); // Load actuator settings back from beginning of manual calibration - actuatorSettingsObj->setData(previousActuatorSettingsData); + actuatorSettingsObj->setData(memento.actuatorSettingsData); ui->configurationWizard->setEnabled(true); ui->saveRCInputToRAM->setEnabled(true); @@ -1781,6 +1798,7 @@ void ConfigInputWidget::resetChannelSettings() for (unsigned int channel = 0; channel < 9; channel++) { manualSettingsData.ChannelGroups[channel] = ManualControlSettings::CHANNELGROUPS_NONE; manualSettingsData.ChannelNumber[channel] = 0; + manualSettingsData.FlightModeNumber = 3; manualSettingsObj->setData(manualSettingsData); } } @@ -1819,7 +1837,7 @@ void ConfigInputWidget::resetActuatorSettings() void ConfigInputWidget::forceOneFlightMode() { - manualCommandData = manualCommandObj->getData(); + manualSettingsData = manualSettingsObj->getData(); manualSettingsData.FlightModeNumber = 1; manualSettingsObj->setData(manualSettingsData); } diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.h b/ground/openpilotgcs/src/plugins/config/configinputwidget.h index de8f38152..fbf4fa71f 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.h @@ -128,21 +128,25 @@ private: ManualControlSettings *manualSettingsObj; ManualControlSettings::DataFields manualSettingsData; - ManualControlSettings::DataFields previousManualSettingsData; ActuatorSettings *actuatorSettingsObj; ActuatorSettings::DataFields actuatorSettingsData; - ActuatorSettings::DataFields previousActuatorSettingsData; FlightModeSettings *flightModeSettingsObj; FlightModeSettings::DataFields flightModeSettingsData; - FlightModeSettings::DataFields previousFlightModeSettingsData; ReceiverActivity *receiverActivityObj; ReceiverActivity::DataFields receiverActivityData; SystemSettings *systemSettingsObj; SystemSettings::DataFields systemSettingsData; - SystemSettings::DataFields previousSystemSettingsData; + + typedef struct { + ManualControlSettings::DataFields manualSettingsData; + ActuatorSettings::DataFields actuatorSettingsData; + FlightModeSettings::DataFields flightModeSettingsData; + SystemSettings::DataFields systemSettingsData; + } Memento; + Memento memento; QSvgRenderer *m_renderer; From 199ee15d84d02270ba999eb9ee4ea4558cc9a343 Mon Sep 17 00:00:00 2001 From: James Duley Date: Wed, 1 Apr 2015 09:19:09 +1300 Subject: [PATCH 30/44] OP-1792 makefile tidy: removed unneeded quotes for OPENSSL that break copydata makefile --- make/tools.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make/tools.mk b/make/tools.mk index fb7ff75b3..3dc0c28cd 100644 --- a/make/tools.mk +++ b/make/tools.mk @@ -776,8 +776,8 @@ ifeq ($(UNAME), Windows) $(eval $(call TOOL_INSTALL_TEMPLATE,openssl,$(OPENSSL_DIR),$(OPENSSL_URL),,$(notdir $(OPENSSL_URL)))) ifeq ($(shell [ -d "$(OPENSSL_DIR)" ] && $(ECHO) "exists"), exists) - export OPENSSL := "$(OPENSSL_DIR)/bin/openssl" - export OPENSSL_DIR := "$(OPENSSL_DIR)" + export OPENSSL := $(OPENSSL_DIR)/bin/openssl + export OPENSSL_DIR else # not installed, hope it's in the path... # $(info $(EMPTY) WARNING $(call toprel, $(OPENSSL_DIR)) not found (make openssl_install), using system PATH) From 91e03a15410c54baf4af035156c68968800abdf5 Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Fri, 3 Apr 2015 12:37:37 +0100 Subject: [PATCH 31/44] OP-1289 Adding tracking of new RadioTx task --- flight/modules/Telemetry/telemetry.c | 4 ++-- shared/uavobjectdefinition/taskinfo.xml | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index ee7e53cda..70b0cf8e4 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -32,7 +32,7 @@ /* Telemetry uses four tasks. Two are created for the main telemetry * stream called "TelTx" and "TelRx". Two are created to handle the OPLink - * radio connection, called "RadioTx" and "Radio Rx", the latter being + * radio connection, called "RadioTx" and "RadioRx", the latter being * overridden by USB if connected. * * The following code uses a "local" prefix to refer to the telemetry channel @@ -193,7 +193,7 @@ int32_t TelemetryStart(void) &radioChannel, TASK_PRIORITY_RADTX, &radioChannel.txTaskHandle); - PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, + PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_RADIOTX, radioChannel.txTaskHandle); xTaskCreate(telemetryRxTask, "RadioRx", diff --git a/shared/uavobjectdefinition/taskinfo.xml b/shared/uavobjectdefinition/taskinfo.xml index 77310cfee..893660676 100644 --- a/shared/uavobjectdefinition/taskinfo.xml +++ b/shared/uavobjectdefinition/taskinfo.xml @@ -23,8 +23,9 @@ TelemetryTx TelemetryRx - + RadioTx RadioRx + Com2UsbBridge Usb2ComBridge @@ -54,8 +55,9 @@ TelemetryTx TelemetryRx - + RadioTx RadioRx + Com2UsbBridge Usb2ComBridge @@ -89,8 +91,9 @@ TelemetryTx TelemetryRx - + RadioTx RadioRx + Com2UsbBridge Usb2ComBridge From 805ee4e9b521b64f472ce1ad160a1cee5c9f5dcf Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sat, 4 Apr 2015 17:21:38 +0200 Subject: [PATCH 32/44] OP-1822 Check visibility and avoid false error that skip Mixer table to populate --- .../plugins/config/cfg_vehicletypes/configccpmwidget.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index a770de2dd..b1f2901cf 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -674,7 +674,6 @@ void ConfigCcpmWidget::UpdateMixer() if (throwConfigError(QString("HeliCP"))) { return; } - GUIConfigDataUnion config = getConfigData(); useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); @@ -1567,28 +1566,28 @@ bool ConfigCcpmWidget::throwConfigError(QString airframeType) bool error = false; - if ((m_aircraft->ccpmServoWChannel->currentIndex() == 0) && (m_aircraft->ccpmServoWChannel->isEnabled())) { + if ((m_aircraft->ccpmServoWChannel->currentIndex() == 0) && (m_aircraft->ccpmServoWChannel->isVisible())) { m_aircraft->ccpmServoWLabel->setText("" + m_aircraft->ccpmServoWLabel->text() + ""); error = true; } else { m_aircraft->ccpmServoWLabel->setText(QTextEdit(m_aircraft->ccpmServoWLabel->text()).toPlainText()); } - if ((m_aircraft->ccpmServoXChannel->currentIndex() == 0) && (m_aircraft->ccpmServoXChannel->isEnabled())) { + if ((m_aircraft->ccpmServoXChannel->currentIndex() == 0) && (m_aircraft->ccpmServoXChannel->isVisible())) { m_aircraft->ccpmServoXLabel->setText("" + m_aircraft->ccpmServoXLabel->text() + ""); error = true; } else { m_aircraft->ccpmServoXLabel->setText(QTextEdit(m_aircraft->ccpmServoXLabel->text()).toPlainText()); } - if ((m_aircraft->ccpmServoYChannel->currentIndex() == 0) && (m_aircraft->ccpmServoYChannel->isEnabled())) { + if ((m_aircraft->ccpmServoYChannel->currentIndex() == 0) && (m_aircraft->ccpmServoYChannel->isVisible())) { m_aircraft->ccpmServoYLabel->setText("" + m_aircraft->ccpmServoYLabel->text() + ""); error = true; } else { m_aircraft->ccpmServoYLabel->setText(QTextEdit(m_aircraft->ccpmServoYLabel->text()).toPlainText()); } - if ((m_aircraft->ccpmServoZChannel->currentIndex() == 0) && (m_aircraft->ccpmServoZChannel->isEnabled())) { + if ((m_aircraft->ccpmServoZChannel->currentIndex() == 0) && (m_aircraft->ccpmServoZChannel->isVisible())) { m_aircraft->ccpmServoZLabel->setText("" + m_aircraft->ccpmServoZLabel->text() + ""); error = true; } else { From aaf635068d579a4c2d5dde32a89e876ff692bf96 Mon Sep 17 00:00:00 2001 From: samguns Date: Mon, 6 Apr 2015 13:10:04 +0800 Subject: [PATCH 33/44] OP-1808 Code change according to review results --- .../src/plugins/config/configinputwidget.cpp | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 4d080406c..48a6ead40 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -42,10 +42,13 @@ #include #include -#define ACCESS_MIN_MOVE -3 -#define ACCESS_MAX_MOVE 3 -#define STICK_MIN_MOVE -8 -#define STICK_MAX_MOVE 8 +#define ACCESS_MIN_MOVE -3 +#define ACCESS_MAX_MOVE 3 +#define STICK_MIN_MOVE -8 +#define STICK_MAX_MOVE 8 + +#define CHANNEL_NUMBER_NONE 0 +#define DEFAULT_FLIGHT_MODE_NUMBER 3 ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent), @@ -888,7 +891,7 @@ void ConfigInputWidget::restoreMdata() */ void ConfigInputWidget::setChannel(int newChan) { - bool canBeSkipped(false); + bool canBeSkipped = false; if (newChan == ManualControlSettings::CHANNELGROUPS_COLLECTIVE) { wizardUi->identifyStickInstructions->setText(QString(tr("

Please enable throttle hold mode.

" @@ -911,7 +914,7 @@ void ConfigInputWidget::setChannel(int newChan) canBeSkipped = true; } - if (true == canBeSkipped) { + if (canBeSkipped) { wizardUi->wzNext->setEnabled(true); wizardUi->wzNext->setText(tr("Next / Skip")); } else { @@ -1795,10 +1798,10 @@ void ConfigInputWidget::resetChannelSettings() { manualSettingsData = manualSettingsObj->getData(); // Clear all channel data : Channel Type (PPM,PWM..) and Number - for (unsigned int channel = 0; channel < 9; channel++) { + for (unsigned int channel = 0; channel < ManualControlSettings::CHANNELNUMBER_NUMELEM; channel++) { manualSettingsData.ChannelGroups[channel] = ManualControlSettings::CHANNELGROUPS_NONE; - manualSettingsData.ChannelNumber[channel] = 0; - manualSettingsData.FlightModeNumber = 3; + manualSettingsData.ChannelNumber[channel] = CHANNEL_NUMBER_NONE; + manualSettingsData.FlightModeNumber = DEFAULT_FLIGHT_MODE_NUMBER; manualSettingsObj->setData(manualSettingsData); } } From af0696048223c0113245983dec4d7623fba2791a Mon Sep 17 00:00:00 2001 From: James Duley Date: Wed, 25 Mar 2015 14:46:52 +1300 Subject: [PATCH 34/44] OP-1792 Makefile tidy: set dependencies for copydata by using new functions addCopyFileTarget and addCopyDirTarget --- ground/openpilotgcs/copydata.pro | 128 +++++++----------- ground/openpilotgcs/openpilotgcs.pri | 51 +++++++ ground/openpilotgcs/share/copydata.pro | 15 +- .../src/libs/sdlgamepad/copydata.pro | 8 +- .../src/plugins/hitl/aerosimrc/src/plugin.pro | 12 +- 5 files changed, 102 insertions(+), 112 deletions(-) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index bf9d7b4d7..94482e4c2 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -4,34 +4,7 @@ TEMPLATE = aux # Copy Qt runtime libraries into the build directory (to run or package) equals(copyqt, 1) { - - # Copy QtQuick2 complete directories - # Some of these directories have a lot of files - # Easier to copy everything - QT_QUICK2_DIRS = QtQuick/Controls \ - QtQuick/Dialogs \ - QtQuick/Layouts \ - QtQuick/LocalStorage \ - QtQuick/Particles.2 \ - QtQuick/PrivateWidgets \ - QtQuick/Window.2 \ - QtQuick/XmlListModel \ - QtQuick.2 - - # create QtQuick directory - data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_QT_QML_PATH/QtQuick\") $$addNewline() - - for(dir, QT_QUICK2_DIRS) { - data_copy.commands += @rm -rf $$targetPath(\"$$GCS_QT_QML_PATH/$$dir\") $$addNewline() - data_copy.commands += $(COPY_DIR) $$targetPath(\"$$[QT_INSTALL_QML]/$$dir\") $$targetPath(\"$$GCS_QT_QML_PATH/$$dir\") $$addNewline() - } - - data_copy.depends = FORCE - QMAKE_EXTRA_TARGETS += data_copy - PRE_TARGETDEPS += data_copy - linux { - QT_LIBS = libQt5Core.so.5 \ libQt5Gui.so.5 \ libQt5Widgets.so.5 \ @@ -57,35 +30,21 @@ equals(copyqt, 1) { libicui18n.so.53 \ libicuuc.so.53 \ libicudata.so.53 - - data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_QT_LIBRARY_PATH\") $$addNewline() for(lib, QT_LIBS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_LIBS]/$$lib\") $$targetPath(\"$$GCS_QT_LIBRARY_PATH/$$lib\") $$addNewline() + addCopyFileTarget($${lib},$$[QT_INSTALL_LIBS],$${GCS_QT_LIBRARY_PATH}) } - # create Qt plugin directories - QT_PLUGIN_DIRS = iconengines \ - imageformats \ - platforms \ - mediaservice \ - sqldrivers - for(dir, QT_PLUGIN_DIRS) { - data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_QT_PLUGINS_PATH/$$dir\") $$addNewline() - } - QT_PLUGIN_LIBS = iconengines/libqsvgicon.so \ - imageformats/libqgif.so \ - imageformats/libqico.so \ - imageformats/libqjpeg.so \ - imageformats/libqmng.so \ - imageformats/libqsvg.so \ - imageformats/libqtiff.so \ - mediaservice/libgstaudiodecoder.so \ - mediaservice/libgstmediaplayer.so \ - platforms/libqxcb.so \ - sqldrivers/libqsqlite.so - for(lib, QT_PLUGIN_LIBS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_PLUGINS]/$$lib\") $$targetPath(\"$$GCS_QT_PLUGINS_PATH/$$lib\") $$addNewline() - } + QT_PLUGINS = iconengines/libqsvgicon.so \ + imageformats/libqgif.so \ + imageformats/libqico.so \ + imageformats/libqjpeg.so \ + imageformats/libqmng.so \ + imageformats/libqsvg.so \ + imageformats/libqtiff.so \ + mediaservice/libgstaudiodecoder.so \ + mediaservice/libgstmediaplayer.so \ + platforms/libqxcb.so \ + sqldrivers/libqsqlite.so } win32 { @@ -121,33 +80,7 @@ equals(copyqt, 1) { libstdc++-6.dll \ libwinpthread-1.dll for(dll, QT_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_BINS]/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() - } - - # create Qt plugin directories - QT_PLUGIN_DIRS = iconengines \ - imageformats \ - platforms \ - mediaservice \ - sqldrivers \ - opengl32_32 - for(dir, QT_PLUGIN_DIRS) { - data_copy.commands += -@$(MKDIR) $$targetPath(\"$$GCS_APP_PATH/$$dir\") $$addNewline() - } - - # copy Qt plugin DLLs - QT_PLUGIN_DLLS = iconengines/qsvgicon$${DS}.dll \ - imageformats/qgif$${DS}.dll \ - imageformats/qico$${DS}.dll \ - imageformats/qjpeg$${DS}.dll \ - imageformats/qmng$${DS}.dll \ - imageformats/qsvg$${DS}.dll \ - imageformats/qtiff$${DS}.dll \ - platforms/qwindows$${DS}.dll \ - mediaservice/dsengine$${DS}.dll \ - sqldrivers/qsqlite$${DS}.dll - for(dll, QT_PLUGIN_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_PLUGINS]/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + addCopyFileTarget($${dll},$$[QT_INSTALL_BINS],$${GCS_APP_PATH}) } # copy OpenSSL DLLs @@ -155,14 +88,45 @@ equals(copyqt, 1) { ssleay32.dll \ libeay32.dll for(dll, OPENSSL_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$${OPENSSL_DIR}/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + addCopyFileTarget($${dll},$${OPENSSL_DIR},$${GCS_APP_PATH}) } # copy OpenGL DLL OPENGL_DLLS = \ opengl32_32/opengl32.dll for(dll, OPENGL_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$${MESAWIN_DIR}/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + addCopyFileTarget($${dll},$${MESAWIN_DIR},$${GCS_APP_PATH}) } + + QT_PLUGINS = iconengines/qsvgicon$${DS}.dll \ + imageformats/qgif$${DS}.dll \ + imageformats/qico$${DS}.dll \ + imageformats/qjpeg$${DS}.dll \ + imageformats/qmng$${DS}.dll \ + imageformats/qsvg$${DS}.dll \ + imageformats/qtiff$${DS}.dll \ + platforms/qwindows$${DS}.dll \ + mediaservice/dsengine$${DS}.dll \ + sqldrivers/qsqlite$${DS}.dll + } + + for(plugin, QT_PLUGINS) { + addCopyFileTarget($${plugin},$$[QT_INSTALL_PLUGINS],$${GCS_QT_PLUGINS_PATH}) + } + + # Copy QtQuick2 complete directories + # Some of these directories have a lot of files + # Easier to copy everything + QT_QUICK2_DIRS = QtQuick/Controls \ + QtQuick/Dialogs \ + QtQuick/Layouts \ + QtQuick/LocalStorage \ + QtQuick/Particles.2 \ + QtQuick/PrivateWidgets \ + QtQuick/Window.2 \ + QtQuick/XmlListModel \ + QtQuick.2 + for(dir, QT_QUICK2_DIRS) { + addCopyDirTarget($${dir},$$[QT_INSTALL_QML],$${GCS_QT_QML_PATH}) } } diff --git a/ground/openpilotgcs/openpilotgcs.pri b/ground/openpilotgcs/openpilotgcs.pri index cbf44dd75..b09693eaf 100644 --- a/ground/openpilotgcs/openpilotgcs.pri +++ b/ground/openpilotgcs/openpilotgcs.pri @@ -32,6 +32,55 @@ defineReplace(qtLibraryName) { return($$RET) } +defineTest(addCopyFileTarget) { + file = $$1 + src = $$2/$$1 + dest = $$3/$$1 + + $${file}.target = $$dest + $${file}.depends = $$src + + # create directory. Better would be an order only dependency + $${file}.commands = -@$(MKDIR) \"$$targetPath($$dirname(dest))\" $$addNewline() + $${file}.commands += $(COPY_FILE) \"$$targetPath($$src)\" \"$$targetPath($$dest)\" + + QMAKE_EXTRA_TARGETS += $$file + POST_TARGETDEPS += $$eval($${file}.target) + + export($${file}.target) + export($${file}.depends) + export($${file}.commands) + export(QMAKE_EXTRA_TARGETS) + export(POST_TARGETDEPS) + + return(true) +} + +defineTest(addCopyDirTarget) { + dir = $$1 + src = $$2/$$1 + dest = $$3/$$1 + + $${dir}.target = $$dest + $${dir}.depends = $$src + + $${dir}.commands = @rm -rf \"$$targetPath($$dest)\" $$addNewline() + # create directory. Better would be an order only dependency + $${dir}.commands += -@$(MKDIR) \"$$targetPath($$dirname(dest))\" $$addNewline() + $${dir}.commands += $(COPY_DIR) \"$$targetPath($$src)\" \"$$targetPath($$dest)\" + + QMAKE_EXTRA_TARGETS += $$dir + POST_TARGETDEPS += $$eval($${dir}.target) + + export($${dir}.target) + export($${dir}.depends) + export($${dir}.commands) + export(QMAKE_EXTRA_TARGETS) + export(POST_TARGETDEPS) + + return(true) +} + # For use in custom compilers which just copy files win32:i_flag = i defineReplace(stripSrcDir) { @@ -119,6 +168,8 @@ macx { contains(TEMPLATE, vc.*)|contains(TEMPLATE_PREFIX, vc):vcproj = 1 GCS_APP_TARGET = openpilotgcs + + GCS_QT_PLUGINS_PATH = $$GCS_APP_PATH GCS_QT_QML_PATH = $$GCS_APP_PATH copyqt = $$copydata diff --git a/ground/openpilotgcs/share/copydata.pro b/ground/openpilotgcs/share/copydata.pro index 2b3a89b6e..b9c2a1875 100644 --- a/ground/openpilotgcs/share/copydata.pro +++ b/ground/openpilotgcs/share/copydata.pro @@ -7,20 +7,7 @@ DATACOLLECTIONS = cloudconfig default_configurations dials models pfd sounds dia equals(copydata, 1) { for(dir, DATACOLLECTIONS) { exists($$GCS_SOURCE_TREE/share/openpilotgcs/$$dir) { - # Qt make macros (CHK_DIR_EXISTS, COPY_DIR, etc) have different syntax. They cannot be used - # reliably to copy subdirectories in two different Windows environments (bash and cmd/QtCreator). - # So undocumented QMAKE_SH variable is used to find out the real environment. - !isEmpty(QMAKE_SH) { - # sh environment (including Windows bash) - data_copy.commands += $(MKDIR) $$targetPath(\"$$GCS_DATA_PATH/$$dir\") $$addNewline() - data_copy.commands += $(COPY_DIR) $$targetPath(\"$$GCS_SOURCE_TREE/share/openpilotgcs/$$dir\") $$targetPath(\"$$GCS_DATA_PATH/\") $$addNewline() - } else { - # native Windows cmd environment - data_copy.commands += $(COPY_DIR) $$targetPath(\"$$GCS_SOURCE_TREE/share/openpilotgcs/$$dir\") $$targetPath(\"$$GCS_DATA_PATH/$$dir\") $$addNewline() - } + addCopyDirTarget($$dir, $$GCS_SOURCE_TREE/share/openpilotgcs, $$GCS_DATA_PATH) } } - data_copy.depends = FORCE - QMAKE_EXTRA_TARGETS += data_copy - PRE_TARGETDEPS += data_copy } diff --git a/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro b/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro index 91cc5292c..af9cecbff 100644 --- a/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro +++ b/ground/openpilotgcs/src/libs/sdlgamepad/copydata.pro @@ -1,16 +1,10 @@ equals(copydata, 1) { - win32 { # copy SDL DLL SDL_DLLS = \ SDL.dll for(dll, SDL_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$${SDL_DIR}/bin/$$dll\") $$targetPath(\"$$GCS_APP_PATH/$$dll\") $$addNewline() + addCopyFileTarget($${dll},$${SDL_DIR}/bin,$${GCS_APP_PATH}) } - - data_copy.depends = FORCE - QMAKE_EXTRA_TARGETS += data_copy - PRE_TARGETDEPS += data_copy } - } diff --git a/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro b/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro index dc809e67d..5f4c57579 100644 --- a/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro +++ b/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro @@ -35,8 +35,6 @@ equals(copydata, 1) { # Windows release only win32:CONFIG(release, debug|release) { - data_copy.commands += -@$(MKDIR) $$targetPath(\"$$PLUGIN_DIR\") $$addNewline() - # resources and sample configuration PLUGIN_RESOURCES = \ cc_off.tga \ @@ -46,7 +44,7 @@ equals(copydata, 1) { cc_plugin.ini \ plugin.txt for(res, PLUGIN_RESOURCES) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$RES_DIR/$$res\") $$targetPath(\"$$PLUGIN_DIR/$$res\") $$addNewline() + addCopyFileTarget($${res},$${RES_DIR},$${PLUGIN_DIR}) } # Qt DLLs @@ -54,7 +52,7 @@ equals(copydata, 1) { Qt5Core.dll \ Qt5Network.dll for(dll, QT_DLLS) { - data_copy.commands += $(COPY_FILE) $$targetPath(\"$$[QT_INSTALL_BINS]/$$dll\") $$targetPath(\"$$SIM_DIR/$$dll\") $$addNewline() + addCopyFileTarget($${dll},$$[QT_INSTALL_BINS],$${SIM_DIR}) } # MinGW DLLs @@ -62,11 +60,7 @@ equals(copydata, 1) { # libgcc_s_dw2-1.dll \ # mingwm10.dll #for(dll, MINGW_DLLS) { - # data_copy.commands += $(COPY_FILE) $$targetPath(\"$$(QTMINGW)/$$dll\") $$targetPath(\"$$SIM_DIR/$$dll\") $$addNewline() + # addCopyFileTarget($${dll},$$(QTMINGW),$${SIM_DIR}) #} - - data_copy.depends = FORCE - QMAKE_EXTRA_TARGETS += data_copy - PRE_TARGETDEPS += data_copy } } From 5ea8a990df7e971816406aec6627eecdf09aa2a5 Mon Sep 17 00:00:00 2001 From: James Duley Date: Tue, 31 Mar 2015 18:59:21 +1300 Subject: [PATCH 35/44] OP-1792 Makefile tidy: removed repeated Qt5OpenGL.dll --- ground/openpilotgcs/copydata.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/ground/openpilotgcs/copydata.pro b/ground/openpilotgcs/copydata.pro index 94482e4c2..eaf91ee08 100644 --- a/ground/openpilotgcs/copydata.pro +++ b/ground/openpilotgcs/copydata.pro @@ -66,7 +66,6 @@ equals(copyqt, 1) { Qt5Script$${DS}.dll \ Qt5Concurrent$${DS}.dll \ Qt5PrintSupport$${DS}.dll \ - Qt5OpenGL$${DS}.dll \ Qt5SerialPort$${DS}.dll \ Qt5Multimedia$${DS}.dll \ Qt5MultimediaWidgets$${DS}.dll \ From ccdd8e226311ddbb6353fdf4ecc1550f3fcdc468 Mon Sep 17 00:00:00 2001 From: James Duley Date: Wed, 1 Apr 2015 10:33:34 +1300 Subject: [PATCH 36/44] OP-1667 removed old firmware line from windows package --- package/winx86/openpilotgcs.nsi | 1 - 1 file changed, 1 deletion(-) diff --git a/package/winx86/openpilotgcs.nsi b/package/winx86/openpilotgcs.nsi index ab8534742..844028159 100644 --- a/package/winx86/openpilotgcs.nsi +++ b/package/winx86/openpilotgcs.nsi @@ -316,7 +316,6 @@ SectionEnd !insertmacro MUI_DESCRIPTION_TEXT ${InSecResources} $(DESC_InSecResources) !insertmacro MUI_DESCRIPTION_TEXT ${InSecSounds} $(DESC_InSecSounds) !insertmacro MUI_DESCRIPTION_TEXT ${InSecLocalization} $(DESC_InSecLocalization) - !insertmacro MUI_DESCRIPTION_TEXT ${InSecFirmware} $(DESC_InSecFirmware) !insertmacro MUI_DESCRIPTION_TEXT ${InSecUtilities} $(DESC_InSecUtilities) !insertmacro MUI_DESCRIPTION_TEXT ${InSecDrivers} $(DESC_InSecDrivers) !insertmacro MUI_DESCRIPTION_TEXT ${InSecInstallDrivers} $(DESC_InSecInstallDrivers) From 68e6231ba13310600120effd80a1c341ac899e92 Mon Sep 17 00:00:00 2001 From: James Duley Date: Wed, 1 Apr 2015 11:08:41 +1300 Subject: [PATCH 37/44] OP-1792 Makefile tidy: removed incorrect alignment space --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f387d96d5..0622cab77 100644 --- a/Makefile +++ b/Makefile @@ -225,7 +225,7 @@ osd_short := 'osd ' revoproto_short := 'revp' simposix_short := 'posx' discoveryf4bare_short := 'df4b' -gpsplatinum_short := 'gps9 ' +gpsplatinum_short := 'gps9' # SimPosix only builds on Linux so drop it from the list for # all other platforms. From 2c241da6391b7092fff50a133e21c255bed36393 Mon Sep 17 00:00:00 2001 From: James Duley Date: Wed, 1 Apr 2015 15:06:04 +1300 Subject: [PATCH 38/44] OP-1792 Makefile tidy: Create a rule for all directories in Makefile --- Makefile | 83 +++++++++++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 0622cab77..ca5c0c88b 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,8 @@ export BUILD_DIR := $(ROOT_DIR)/build export PACKAGE_DIR := $(ROOT_DIR)/build/package export DIST_DIR := $(ROOT_DIR)/build/dist +DIRS = $(DL_DIR) $(TOOLS_DIR) $(BUILD_DIR) $(PACKAGE_DIR) $(DIST_DIR) + # Set up default build configurations (debug | release) GCS_BUILD_CONF := release UAVOGEN_BUILD_CONF := release @@ -140,20 +142,6 @@ all_clean: .PONY: clean clean: all_clean -$(DL_DIR): - $(MKDIR) -p $@ - -$(TOOLS_DIR): - $(MKDIR) -p $@ - -$(BUILD_DIR): - $(MKDIR) -p $@ - -$(PACKAGE_DIR): - $(MKDIR) -p $@ - -$(DIST_DIR): - $(MKDIR) -p $@ ############################## # @@ -167,10 +155,12 @@ else UAVOGEN_SILENT := silent endif +UAVOBJGENERATOR_DIR = $(BUILD_DIR)/uavobjgenerator +DIRS += $(UAVOBJGENERATOR_DIR) + .PHONY: uavobjgenerator -uavobjgenerator: - $(V1) $(MKDIR) -p $(BUILD_DIR)/$@ - $(V1) ( cd $(BUILD_DIR)/$@ && \ +uavobjgenerator: | $(UAVOBJGENERATOR_DIR) + $(V1) ( cd $(UAVOBJGENERATOR_DIR) && \ $(QMAKE) $(ROOT_DIR)/ground/uavobjgenerator/uavobjgenerator.pro -spec $(QT_SPEC) -r CONFIG+="$(UAVOGEN_BUILD_CONF) $(UAVOGEN_SILENT)" && \ $(MAKE) --no-print-directory -w ; \ ) @@ -183,8 +173,7 @@ uavobjects: $(addprefix uavobjects_, $(UAVOBJ_TARGETS)) UAVOBJ_XML_DIR := $(ROOT_DIR)/shared/uavobjectdefinition UAVOBJ_OUT_DIR := $(BUILD_DIR)/uavobject-synthetics -$(UAVOBJ_OUT_DIR): - $(V1) $(MKDIR) -p $@ +DIRS += $(UAVOBJ_OUT_DIR) uavobjects_%: $(UAVOBJ_OUT_DIR) uavobjgenerator $(V1) ( cd $(UAVOBJ_OUT_DIR) && \ @@ -214,6 +203,8 @@ export OPUAVTALK := $(ROOT_DIR)/flight/uavtalk export OPUAVSYNTHDIR := $(BUILD_DIR)/uavobject-synthetics/flight export OPGCSSYNTHDIR := $(BUILD_DIR)/openpilotgcs-synthetics +DIRS += $(OPGCSSYNTHDIR) + # Define supported board lists ALL_BOARDS := coptercontrol oplinkmini revolution osd revoproto simposix discoveryf4bare gpsplatinum @@ -474,11 +465,13 @@ endif .PHONY: openpilotgcs openpilotgcs: uavobjects_gcs openpilotgcs_qmake openpilotgcs_make +OPENPILOTGCS_DIR := $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF) +DIRS += $(OPENPILOTGCS_DIR) + .PHONY: openpilotgcs_qmake -openpilotgcs_qmake: +openpilotgcs_qmake: | $(OPENPILOTGCS_DIR) ifeq ($(QMAKE_SKIP),) - $(V1) $(MKDIR) -p $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF) - $(V1) ( cd $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF) && \ + $(V1) ( cd $(OPENPILOTGCS_DIR) && \ $(QMAKE) $(ROOT_DIR)/ground/openpilotgcs/openpilotgcs.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) \ ) else @@ -487,15 +480,12 @@ endif .PHONY: openpilotgcs_make openpilotgcs_make: - $(V1) $(MKDIR) -p $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF) - $(V1) ( cd $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF)/$(MAKE_DIR) && \ - $(MAKE) -w ; \ - ) + $(V1) $(MAKE) -w -C $(OPENPILOTGCS_DIR)/$(MAKE_DIR); .PHONY: openpilotgcs_clean openpilotgcs_clean: - @$(ECHO) " CLEAN $(call toprel, $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF))" - $(V1) [ ! -d "$(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF)" ] || $(RM) -r "$(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF)" + @$(ECHO) " CLEAN $(call toprel, $(OPENPILOTGCS_DIR))" + $(V1) [ ! -d "$(OPENPILOTGCS_DIR)" ] || $(RM) -r "$(OPENPILOTGCS_DIR)" ################################ # @@ -507,11 +497,13 @@ openpilotgcs_clean: .PHONY: uploader uploader: uploader_qmake uploader_make +UPLOADER_DIR := $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF) +DIRS += $(UPLOADER_DIR) + .PHONY: uploader_qmake -uploader_qmake: +uploader_qmake: | $(UPLOADER_DIR) ifeq ($(QMAKE_SKIP),) - $(V1) $(MKDIR) -p $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF) - $(V1) ( cd $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF) && \ + $(V1) ( cd $(UPLOADER_DIR) && \ $(QMAKE) $(ROOT_DIR)/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/upload.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) \ ) else @@ -520,15 +512,12 @@ endif .PHONY: uploader_make uploader_make: - $(V1) $(MKDIR) -p $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF) - $(V1) ( cd $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)/$(MAKE_DIR) && \ - $(MAKE) -w ; \ - ) + $(V1) $(MAKE) -w -C $(UPLOADER_DIR) .PHONY: uploader_clean uploader_clean: - @$(ECHO) " CLEAN $(call toprel, $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF))" - $(V1) [ ! -d "$(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)" ] || $(RM) -r "$(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)" + @$(ECHO) " CLEAN $(call toprel, $(UPLOADER_DIR))" + $(V1) [ ! -d "$(UPLOADER_DIR)" ] || $(RM) -r "$(UPLOADER_DIR)" # We want to take snapshots of the UAVOs at each point that they change @@ -652,8 +641,7 @@ ALL_UNITTESTS := logfs math lednotification # Build the directory for the unit tests UT_OUT_DIR := $(BUILD_DIR)/unit_tests -$(UT_OUT_DIR): - $(V1) $(MKDIR) -p $@ +DIRS += $(UT_OUT_DIR) .PHONY: all_ut all_ut: $(addsuffix _elf, $(addprefix ut_, $(ALL_UNITTESTS))) @@ -728,9 +716,8 @@ OPFW_CONTENTS := \ .PHONY: opfw_resource opfw_resource: $(OPFW_RESOURCE) -$(OPFW_RESOURCE): $(FW_TARGETS) +$(OPFW_RESOURCE): $(FW_TARGETS) | $(OPGCSSYNTHDIR) @$(ECHO) Generating OPFW resource file $(call toprel, $@) - $(V1) $(MKDIR) -p $(dir $@) $(V1) $(ECHO) $(QUOTE)$(OPFW_CONTENTS)$(QUOTE) > $@ # If opfw_resource or all firmware are requested, GCS should depend on the resource @@ -821,9 +808,8 @@ docs_all_clean: ############################## .PHONY: build-info -build-info: +build-info: | $(BUILD_DIR) @$(ECHO) " BUILD-INFO $(call toprel, $(BUILD_DIR)/$@.txt)" - $(V1) $(MKDIR) -p $(BUILD_DIR) $(V1) $(VERSION_INFO) \ --uavodir=$(ROOT_DIR)/shared/uavobjectdefinition \ --template="make/templates/$@.txt" \ @@ -852,6 +838,17 @@ $(DIST_NAME).gz: $(DIST_VER_INFO) .git/index | $(DIST_DIR) .PHONY: dist dist: $(DIST_NAME).gz + +############################## +# +# Directories +# +############################## + +$(DIRS): + $(V1) $(MKDIR) -p $@ + + ############################## # # Help message, the default Makefile goal From acdba01d4d139c393807fd9991999bdaf1bb4ff0 Mon Sep 17 00:00:00 2001 From: James Duley Date: Thu, 2 Apr 2015 09:26:37 +1300 Subject: [PATCH 39/44] OP-1792 Maefile tidy: Rewrote ground build so qmake is only run by defualt on first build --- Makefile | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index ca5c0c88b..6860634c6 100644 --- a/Makefile +++ b/Makefile @@ -451,8 +451,9 @@ sim_osx_%: uavobjects_flight all_ground: openpilotgcs uploader # Convenience target for the GCS -.PHONY: gcs gcs_clean +.PHONY: gcs gcs_qmake gcs_clean gcs: openpilotgcs +gcs_qmake: openpilotgcs_qmake gcs_clean: openpilotgcs_clean ifeq ($(V), 1) @@ -461,25 +462,19 @@ else GCS_SILENT := silent endif -.NOTPARALLEL: -.PHONY: openpilotgcs -openpilotgcs: uavobjects_gcs openpilotgcs_qmake openpilotgcs_make - OPENPILOTGCS_DIR := $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF) DIRS += $(OPENPILOTGCS_DIR) +OPENPILOTGCS_MAKEFILE := $(OPENPILOTGCS_DIR)/Makefile + .PHONY: openpilotgcs_qmake -openpilotgcs_qmake: | $(OPENPILOTGCS_DIR) -ifeq ($(QMAKE_SKIP),) +openpilotgcs_qmake $(OPENPILOTGCS_MAKEFILE): | $(OPENPILOTGCS_DIR) $(V1) ( cd $(OPENPILOTGCS_DIR) && \ $(QMAKE) $(ROOT_DIR)/ground/openpilotgcs/openpilotgcs.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) \ ) -else - @$(ECHO) "skipping qmake" -endif -.PHONY: openpilotgcs_make -openpilotgcs_make: +.PHONY: openpilotgcs +openpilotgcs: uavobjects_gcs $(OPENPILOTGCS_MAKEFILE) $(V1) $(MAKE) -w -C $(OPENPILOTGCS_DIR)/$(MAKE_DIR); .PHONY: openpilotgcs_clean @@ -493,25 +488,19 @@ openpilotgcs_clean: # ################################ -.NOTPARALLEL: -.PHONY: uploader -uploader: uploader_qmake uploader_make - UPLOADER_DIR := $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF) DIRS += $(UPLOADER_DIR) +UPLOADER_MAKEFILE := $(UPLOADER_DIR)/Makefile + .PHONY: uploader_qmake -uploader_qmake: | $(UPLOADER_DIR) -ifeq ($(QMAKE_SKIP),) +uploader_qmake $(UPLOADER_MAKEFILE): | $(UPLOADER_DIR) $(V1) ( cd $(UPLOADER_DIR) && \ $(QMAKE) $(ROOT_DIR)/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/upload.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) \ ) -else - @$(ECHO) "skipping qmake" -endif -.PHONY: uploader_make -uploader_make: +.PHONY: uploader +uploader: $(UPLOADER_MAKEFILE) $(V1) $(MAKE) -w -C $(UPLOADER_DIR) .PHONY: uploader_clean @@ -953,16 +942,15 @@ help: @$(ECHO) @$(ECHO) " [GCS]" @$(ECHO) " gcs - Build the Ground Control System (GCS) application (debug|release)" - @$(ECHO) " Skip qmake: QMAKE_SKIP=1" @$(ECHO) " Compile specific directory: MAKE_DIR=" - @$(ECHO) " Example: make gcs QMAKE_SKIP=1 MAKE_DIR=src/plugins/coreplugin" + @$(ECHO) " Example: make gcs MAKE_DIR=src/plugins/coreplugin" + @$(ECHO) " gcs_qmake - Run qmake for the Ground Control System (GCS) application (debug|release)" @$(ECHO) " gcs_clean - Remove the Ground Control System (GCS) application (debug|release)" @$(ECHO) " Supported build configurations: GCS_BUILD_CONF=debug|release (default is $(GCS_BUILD_CONF))" @$(ECHO) @$(ECHO) " [Uploader Tool]" @$(ECHO) " uploader - Build the serial uploader tool (debug|release)" - @$(ECHO) " Skip qmake: QMAKE_SKIP=1" - @$(ECHO) " Example: make uploader QMAKE_SKIP=1" + @$(ECHO) " uploader_qmake - Run qmake for the serial uploader tool (debug|release)" @$(ECHO) " uploader_clean - Remove the serial uploader tool (debug|release)" @$(ECHO) " Supported build configurations: GCS_BUILD_CONF=debug|release (default is $(GCS_BUILD_CONF))" @$(ECHO) From 50ce26bd80966c1e41ea0f24d96868bfc92b7933 Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Sat, 11 Apr 2015 10:06:19 +0100 Subject: [PATCH 40/44] OP-1803 Only create local telemetry queues/tasks if needed --- flight/modules/Telemetry/telemetry.c | 134 +++++++++++++++------------ 1 file changed, 76 insertions(+), 58 deletions(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index 70b0cf8e4..9d3d1d5e6 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -157,36 +157,45 @@ static void updateSettings(channelContext *channel); */ int32_t TelemetryStart(void) { - UAVObjIterate(®isterLocalObject); + // Only start the local telemetry tasks if needed + if (localPort()) { + UAVObjIterate(®isterLocalObject); + + // Listen to objects of interest +#ifdef PIOS_TELEM_PRIORITY_QUEUE + GCSTelemetryStatsConnectQueue(localChannel.priorityQueue); +#else /* PIOS_TELEM_PRIORITY_QUEUE */ + GCSTelemetryStatsConnectQueue(localChannel.queue); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ + // Start telemetry tasks + xTaskCreate(telemetryTxTask, + "TelTx", + STACK_SIZE_TX_BYTES / 4, + &localChannel, + TASK_PRIORITY_TX, + &localChannel.txTaskHandle); + PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, + localChannel.txTaskHandle); + xTaskCreate(telemetryRxTask, + "TelRx", + STACK_SIZE_RX_BYTES / 4, + &localChannel, + TASK_PRIORITY_RX, + &localChannel.rxTaskHandle); + PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX, + localChannel.rxTaskHandle); + } + + // Start the telemetry tasks associated with Radio/USB UAVObjIterate(®isterRadioObject); // Listen to objects of interest #ifdef PIOS_TELEM_PRIORITY_QUEUE - GCSTelemetryStatsConnectQueue(localChannel.priorityQueue); GCSTelemetryStatsConnectQueue(radioChannel.priorityQueue); #else /* PIOS_TELEM_PRIORITY_QUEUE */ - GCSTelemetryStatsConnectQueue(localChannel.queue); GCSTelemetryStatsConnectQueue(radioChannel.queue); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ - // Start telemetry tasks - xTaskCreate(telemetryTxTask, - "TelTx", - STACK_SIZE_TX_BYTES / 4, - &localChannel, - TASK_PRIORITY_TX, - &localChannel.txTaskHandle); - PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, - localChannel.txTaskHandle); - xTaskCreate(telemetryRxTask, - "TelRx", - STACK_SIZE_RX_BYTES / 4, - &localChannel, - TASK_PRIORITY_RX, - &localChannel.rxTaskHandle); - PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX, - localChannel.rxTaskHandle); - xTaskCreate(telemetryTxTask, "RadioTx", STACK_SIZE_RADIO_TX_BYTES / 4, @@ -207,6 +216,35 @@ int32_t TelemetryStart(void) return 0; } +/* Intialise a telemetry channel */ +void TelemetryInitializeChannel(channelContext *channel) +{ + // Create object queues + channel->queue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); +#if defined(PIOS_TELEM_PRIORITY_QUEUE) + channel->priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ + + // Initialise UAVTalk + channel->uavTalkCon = UAVTalkInitialize(&transmitLocalData); + + // Create periodic event that will be used to update the telemetry stats + UAVObjEvent ev; + memset(&ev, 0, sizeof(UAVObjEvent)); + +#ifdef PIOS_TELEM_PRIORITY_QUEUE + EventPeriodicQueueCreate(&ev, + channel->priorityQueue, + STATS_UPDATE_PERIOD_MS); +#else /* PIOS_TELEM_PRIORITY_QUEUE */ + EventPeriodicQueueCreate(&ev, + channel->queue, + STATS_UPDATE_PERIOD_MS); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ +} + /** * Initialise the telemetry module * \return -1 if initialisation failed @@ -214,58 +252,38 @@ int32_t TelemetryStart(void) */ int32_t TelemetryInitialize(void) { + HwSettingsInitialize(); + FlightTelemetryStatsInitialize(); GCSTelemetryStatsInitialize(); // Initialize vars - timeOfLastObjectUpdate = 0; + timeOfLastObjectUpdate = 0; - // Create object queues - localChannel.queue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); - radioChannel.queue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); -#if defined(PIOS_TELEM_PRIORITY_QUEUE) - localChannel.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); - radioChannel.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); -#endif /* PIOS_TELEM_PRIORITY_QUEUE */ + // Reset link stats + txErrors = 0; + txRetries = 0; // Set channel port handlers localChannel.getPort = localPort; radioChannel.getPort = radioPort; - HwSettingsInitialize(); + // Set the local telemetry baud rate updateSettings(&localChannel); + // Only initialise local channel if telemetry port enabled + if (localPort()) { + // Initialise channel + TelemetryInitializeChannel(&localChannel); + // Initialise UAVTalk + localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData); + } + + // Initialise channel + TelemetryInitializeChannel(&radioChannel); // Initialise UAVTalk - localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData); radioChannel.uavTalkCon = UAVTalkInitialize(&transmitRadioData); - // Create periodic event that will be used to update the telemetry stats - // FIXME STATS_UPDATE_PERIOD_MS is 4000ms while FlighTelemetryStats update period is 5000ms... - txErrors = 0; - txRetries = 0; - UAVObjEvent ev; - memset(&ev, 0, sizeof(UAVObjEvent)); - -#ifdef PIOS_TELEM_PRIORITY_QUEUE - EventPeriodicQueueCreate(&ev, - localChannel.priorityQueue, - STATS_UPDATE_PERIOD_MS); - EventPeriodicQueueCreate(&ev, - radioChannel.priorityQueue, - STATS_UPDATE_PERIOD_MS); -#else /* PIOS_TELEM_PRIORITY_QUEUE */ - EventPeriodicQueueCreate(&ev, - localChannel.queue, - STATS_UPDATE_PERIOD_MS); - EventPeriodicQueueCreate(&ev, - radioChannel.queue, - STATS_UPDATE_PERIOD_MS); -#endif /* PIOS_TELEM_PRIORITY_QUEUE */ - return 0; } From 24defde93bf946a9da4852fe8746fbf234b6012e Mon Sep 17 00:00:00 2001 From: James Duley Date: Sat, 11 Apr 2015 23:20:30 +1200 Subject: [PATCH 41/44] OP-1792 Makefile tidy: fix addCopyDirTarget on windows because directory timestamps are not updated when a file is modified --- ground/openpilotgcs/openpilotgcs.pri | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ground/openpilotgcs/openpilotgcs.pri b/ground/openpilotgcs/openpilotgcs.pri index b09693eaf..3141d1832 100644 --- a/ground/openpilotgcs/openpilotgcs.pri +++ b/ground/openpilotgcs/openpilotgcs.pri @@ -63,6 +63,8 @@ defineTest(addCopyDirTarget) { $${dir}.target = $$dest $${dir}.depends = $$src + # Windows does not update directory timestamp if files are modified + win32: $${dir}.depends += FORCE $${dir}.commands = @rm -rf \"$$targetPath($$dest)\" $$addNewline() # create directory. Better would be an order only dependency From 32a25e7044ae812d239d0b71b9051338db846ab3 Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Sat, 11 Apr 2015 10:06:19 +0100 Subject: [PATCH 42/44] OP-1289 Only create local telemetry queues/tasks if needed --- flight/modules/Telemetry/telemetry.c | 134 +++++++++++++++------------ 1 file changed, 76 insertions(+), 58 deletions(-) diff --git a/flight/modules/Telemetry/telemetry.c b/flight/modules/Telemetry/telemetry.c index 70b0cf8e4..9d3d1d5e6 100644 --- a/flight/modules/Telemetry/telemetry.c +++ b/flight/modules/Telemetry/telemetry.c @@ -157,36 +157,45 @@ static void updateSettings(channelContext *channel); */ int32_t TelemetryStart(void) { - UAVObjIterate(®isterLocalObject); + // Only start the local telemetry tasks if needed + if (localPort()) { + UAVObjIterate(®isterLocalObject); + + // Listen to objects of interest +#ifdef PIOS_TELEM_PRIORITY_QUEUE + GCSTelemetryStatsConnectQueue(localChannel.priorityQueue); +#else /* PIOS_TELEM_PRIORITY_QUEUE */ + GCSTelemetryStatsConnectQueue(localChannel.queue); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ + // Start telemetry tasks + xTaskCreate(telemetryTxTask, + "TelTx", + STACK_SIZE_TX_BYTES / 4, + &localChannel, + TASK_PRIORITY_TX, + &localChannel.txTaskHandle); + PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, + localChannel.txTaskHandle); + xTaskCreate(telemetryRxTask, + "TelRx", + STACK_SIZE_RX_BYTES / 4, + &localChannel, + TASK_PRIORITY_RX, + &localChannel.rxTaskHandle); + PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX, + localChannel.rxTaskHandle); + } + + // Start the telemetry tasks associated with Radio/USB UAVObjIterate(®isterRadioObject); // Listen to objects of interest #ifdef PIOS_TELEM_PRIORITY_QUEUE - GCSTelemetryStatsConnectQueue(localChannel.priorityQueue); GCSTelemetryStatsConnectQueue(radioChannel.priorityQueue); #else /* PIOS_TELEM_PRIORITY_QUEUE */ - GCSTelemetryStatsConnectQueue(localChannel.queue); GCSTelemetryStatsConnectQueue(radioChannel.queue); #endif /* PIOS_TELEM_PRIORITY_QUEUE */ - // Start telemetry tasks - xTaskCreate(telemetryTxTask, - "TelTx", - STACK_SIZE_TX_BYTES / 4, - &localChannel, - TASK_PRIORITY_TX, - &localChannel.txTaskHandle); - PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYTX, - localChannel.txTaskHandle); - xTaskCreate(telemetryRxTask, - "TelRx", - STACK_SIZE_RX_BYTES / 4, - &localChannel, - TASK_PRIORITY_RX, - &localChannel.rxTaskHandle); - PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_TELEMETRYRX, - localChannel.rxTaskHandle); - xTaskCreate(telemetryTxTask, "RadioTx", STACK_SIZE_RADIO_TX_BYTES / 4, @@ -207,6 +216,35 @@ int32_t TelemetryStart(void) return 0; } +/* Intialise a telemetry channel */ +void TelemetryInitializeChannel(channelContext *channel) +{ + // Create object queues + channel->queue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); +#if defined(PIOS_TELEM_PRIORITY_QUEUE) + channel->priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, + sizeof(UAVObjEvent)); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ + + // Initialise UAVTalk + channel->uavTalkCon = UAVTalkInitialize(&transmitLocalData); + + // Create periodic event that will be used to update the telemetry stats + UAVObjEvent ev; + memset(&ev, 0, sizeof(UAVObjEvent)); + +#ifdef PIOS_TELEM_PRIORITY_QUEUE + EventPeriodicQueueCreate(&ev, + channel->priorityQueue, + STATS_UPDATE_PERIOD_MS); +#else /* PIOS_TELEM_PRIORITY_QUEUE */ + EventPeriodicQueueCreate(&ev, + channel->queue, + STATS_UPDATE_PERIOD_MS); +#endif /* PIOS_TELEM_PRIORITY_QUEUE */ +} + /** * Initialise the telemetry module * \return -1 if initialisation failed @@ -214,58 +252,38 @@ int32_t TelemetryStart(void) */ int32_t TelemetryInitialize(void) { + HwSettingsInitialize(); + FlightTelemetryStatsInitialize(); GCSTelemetryStatsInitialize(); // Initialize vars - timeOfLastObjectUpdate = 0; + timeOfLastObjectUpdate = 0; - // Create object queues - localChannel.queue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); - radioChannel.queue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); -#if defined(PIOS_TELEM_PRIORITY_QUEUE) - localChannel.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); - radioChannel.priorityQueue = xQueueCreate(MAX_QUEUE_SIZE, - sizeof(UAVObjEvent)); -#endif /* PIOS_TELEM_PRIORITY_QUEUE */ + // Reset link stats + txErrors = 0; + txRetries = 0; // Set channel port handlers localChannel.getPort = localPort; radioChannel.getPort = radioPort; - HwSettingsInitialize(); + // Set the local telemetry baud rate updateSettings(&localChannel); + // Only initialise local channel if telemetry port enabled + if (localPort()) { + // Initialise channel + TelemetryInitializeChannel(&localChannel); + // Initialise UAVTalk + localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData); + } + + // Initialise channel + TelemetryInitializeChannel(&radioChannel); // Initialise UAVTalk - localChannel.uavTalkCon = UAVTalkInitialize(&transmitLocalData); radioChannel.uavTalkCon = UAVTalkInitialize(&transmitRadioData); - // Create periodic event that will be used to update the telemetry stats - // FIXME STATS_UPDATE_PERIOD_MS is 4000ms while FlighTelemetryStats update period is 5000ms... - txErrors = 0; - txRetries = 0; - UAVObjEvent ev; - memset(&ev, 0, sizeof(UAVObjEvent)); - -#ifdef PIOS_TELEM_PRIORITY_QUEUE - EventPeriodicQueueCreate(&ev, - localChannel.priorityQueue, - STATS_UPDATE_PERIOD_MS); - EventPeriodicQueueCreate(&ev, - radioChannel.priorityQueue, - STATS_UPDATE_PERIOD_MS); -#else /* PIOS_TELEM_PRIORITY_QUEUE */ - EventPeriodicQueueCreate(&ev, - localChannel.queue, - STATS_UPDATE_PERIOD_MS); - EventPeriodicQueueCreate(&ev, - radioChannel.queue, - STATS_UPDATE_PERIOD_MS); -#endif /* PIOS_TELEM_PRIORITY_QUEUE */ - return 0; } From 9cb09260092b801389f5ad8f509f06f3a8f4687b Mon Sep 17 00:00:00 2001 From: Mathieu Rondonneau Date: Tue, 24 Mar 2015 21:12:43 -0700 Subject: [PATCH 43/44] OP-1804: Add realloc. --- flight/pios/common/libraries/msheap/msheap.c | 55 ++++++++++++++++++- flight/pios/common/libraries/msheap/msheap.h | 2 +- .../common/libraries/msheap/pios_msheap.c | 12 ++-- flight/pios/common/pios_mem.c | 38 +++++++++++-- flight/pios/inc/pios_mem.h | 2 + 5 files changed, 97 insertions(+), 12 deletions(-) diff --git a/flight/pios/common/libraries/msheap/msheap.c b/flight/pios/common/libraries/msheap/msheap.c index 2d88981eb..a359d5072 100644 --- a/flight/pios/common/libraries/msheap/msheap.c +++ b/flight/pios/common/libraries/msheap/msheap.c @@ -194,13 +194,18 @@ msheap_init(heap_handle_t *heap, void *base, void *limit) } void * -msheap_alloc(heap_handle_t *heap, uint32_t size) +msheap_alloc(heap_handle_t *heap, void *ptr, uint32_t size) { marker_t cursor; marker_t best; + uint32_t copy_data = 0; + uint16_t old_size = 0; ASSERT(3, msheap_check(heap)); + if (size == 0) + return 0; + /* convert the passed-in size to the number of marker-size units we need to allocate */ size += marker_size; size = round_up(size, marker_size); @@ -210,6 +215,39 @@ msheap_alloc(heap_handle_t *heap, uint32_t size) if (size > heap->heap_free) return 0; + /* realloc */ + if (ptr != 0) { + + best = (marker_t)ptr - 1; + ASSERT(0, region_check(heap, best)); + ASSERT(3, msheap_check(heap)); + +#ifdef HEAP_REALLOC_FREE_UNUSED_AREA + + if (best->next.size == size) + goto done; + + if (best->next.size > size) { + /* this region is free, mark it accordingly */ + best->next.free = 1; + (best + best->next.size)->prev.free = 1; + + traceFREE( ptr, best->next.size ); + + /* account for space we are freeing */ + heap->heap_free += best->next.size; + + goto split; + } +#else + if (best->next.size >= size) + goto done; +#endif + old_size = best->next.size; + msheap_free(heap, ptr); + copy_data = 1; + } + /* simple single-pass best-fit search */ restart: cursor = heap->free_hint; @@ -242,13 +280,28 @@ restart: /* no space */ return 0; } +#ifdef HEAP_REALLOC_FREE_UNUSED_AREA +split: +#endif /* split the free region to make space */ split_region(heap, best, size); /* update free space counter */ heap->heap_free -= size; + +done: traceMALLOC( (void *)(best + 1), size ); + + /* Copy data that might be reused */ + if (copy_data && ptr) { + size = old_size; + size = size - 1; + size *= marker_size; + for(uint32_t i=0 ; i < size; i++) + ((uint8_t *)(best + 1))[i] = ((uint8_t *)ptr)[i]; + } + /* and return a pointer to the allocated region */ return (void *)(best + 1); } diff --git a/flight/pios/common/libraries/msheap/msheap.h b/flight/pios/common/libraries/msheap/msheap.h index a45d08b1e..17aa47c59 100644 --- a/flight/pios/common/libraries/msheap/msheap.h +++ b/flight/pios/common/libraries/msheap/msheap.h @@ -116,7 +116,7 @@ extern void msheap_init(heap_handle_t *heap, void *base, void *limit); * * @param size The number of bytes required (more may be allocated). */ -extern void *msheap_alloc(heap_handle_t *heap, uint32_t size); +extern void *msheap_alloc(heap_handle_t *heap, void *ptr, uint32_t size); /** * Free memory back to the heap. diff --git a/flight/pios/common/libraries/msheap/pios_msheap.c b/flight/pios/common/libraries/msheap/pios_msheap.c index d989213f5..9ce9f7b8a 100644 --- a/flight/pios/common/libraries/msheap/pios_msheap.c +++ b/flight/pios/common/libraries/msheap/pios_msheap.c @@ -74,15 +74,15 @@ heap_handle_t fast_heap; extern void vApplicationMallocFailedHook(void) __attribute__((weak)); void * -pios_general_malloc(size_t s, bool use_fast_heap) +pios_general_malloc(void *ptr, size_t s, bool use_fast_heap) { void *p; vPortEnterCritical(); if(use_fast_heap){ - p = msheap_alloc(&fast_heap, s); + p = msheap_alloc(&fast_heap, ptr, s); } else { - p = msheap_alloc(&sram_heap, s); + p = msheap_alloc(&sram_heap, ptr, s); } vPortExitCritical(); @@ -95,13 +95,13 @@ pios_general_malloc(size_t s, bool use_fast_heap) void * pvPortMalloc(size_t s) { - return pios_general_malloc(s, true); + return pios_general_malloc(NULL, s, true); } void * pvPortMallocStack(size_t s) { - return pios_general_malloc(s, false); + return pios_general_malloc(NULL, s, false); } void @@ -154,7 +154,7 @@ malloc(size_t size) heap_init_done = 1; } - return msheap_alloc(sram_heap, size); + return msheap_alloc(NULL, sram_heap, size); } void diff --git a/flight/pios/common/pios_mem.c b/flight/pios/common/pios_mem.c index 6d4526995..bf0166bae 100644 --- a/flight/pios/common/pios_mem.c +++ b/flight/pios/common/pios_mem.c @@ -29,17 +29,32 @@ #ifdef PIOS_TARGET_PROVIDES_FAST_HEAP // relies on pios_general_malloc to perform the allocation (i.e. pios_msheap.c) -extern void *pios_general_malloc(size_t size, bool fastheap); +extern void *pios_general_malloc(void *ptr, size_t size, bool fastheap); void *pios_fastheapmalloc(size_t size) { - return pios_general_malloc(size, true); + return pios_general_malloc(NULL, size, true); } void *pios_malloc(size_t size) { - return pios_general_malloc(size, false); + return pios_general_malloc(NULL, size, false); +} + +void *pios_realloc(__attribute__((unused)) void *ptr, __attribute__((unused)) size_t size) +{ +#ifdef PIOS_INCLUDE_REALLOC + return pios_general_malloc(ptr, size, false); + +#else + // Not allowed to use realloc without the proper define PIOS_INCLUDE_REALLOC set + while (1) { + ; + } + return NULL; + +#endif } void pios_free(void *p) @@ -47,7 +62,7 @@ void pios_free(void *p) vPortFree(p); } -#else +#else /* ifdef PIOS_TARGET_PROVIDES_FAST_HEAP */ // demand to pvPortMalloc implementation void *pios_fastheapmalloc(size_t size) { @@ -60,6 +75,21 @@ void *pios_malloc(size_t size) return pvPortMalloc(size); } +void *pios_realloc(__attribute__((unused)) void *ptr, __attribute__((unused)) size_t size) +{ +#ifdef PIOS_INCLUDE_REALLOC + return pvPortMalloc(size); + +#else + // Not allowed to use realloc without the proper define PIOS_INCLUDE_REALLOC set + while (1) { + ; + } + return NULL; + +#endif +} + void pios_free(void *p) { vPortFree(p); diff --git a/flight/pios/inc/pios_mem.h b/flight/pios/inc/pios_mem.h index 6ec85f30b..079f51d59 100644 --- a/flight/pios/inc/pios_mem.h +++ b/flight/pios/inc/pios_mem.h @@ -32,6 +32,8 @@ void *pios_fastheapmalloc(size_t size); void *pios_malloc(size_t size); +void *pios_realloc(void *ptr, size_t size); + void pios_free(void *p); #endif /* PIOS_MEM_H */ From fe04a9b63c4b62fbf50647cfffc22095ae8be86d Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sat, 18 Apr 2015 13:55:50 +0200 Subject: [PATCH 44/44] OP-1337 French translation update : Usage feedback --- .../translations/openpilotgcs_fr.ts | 60 ++++++++++++++++--- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/translations/openpilotgcs_fr.ts b/ground/openpilotgcs/share/openpilotgcs/translations/openpilotgcs_fr.ts index 66c09537a..4a03fec6f 100644 --- a/ground/openpilotgcs/share/openpilotgcs/translations/openpilotgcs_fr.ts +++ b/ground/openpilotgcs/share/openpilotgcs/translations/openpilotgcs_fr.ts @@ -52,7 +52,7 @@ - + General Général @@ -68,7 +68,7 @@ <Langue Système> - + Variables Variables @@ -103,22 +103,35 @@ Sélectionner automatiquement un périphérique USB OpenPilot : - Use UDP Mirror Typo need ":" or remove on others - Utiliser Miroir UDP + Utiliser Miroir UDP - Expert Mode Typo need ":" or remove on others - Mode Expert + Mode Expert Language: Langue : + + + Expert Mode: + Mode Expert : + + + + Contribute usage statistics: + Contribuer aux statistiques d'utilisation : + + + + Use UDP Mirror: + Utiliser Miroir UDP : + Core::Internal::MainWindow @@ -16173,7 +16186,7 @@ IMPORTANT : Ces nouveaux paramètres ne sont pas encore enregistrés sur la cart ConfigCcpmWidget - + <h1>Swashplate Leveling Routine</h1> @@ -16320,4 +16333,37 @@ Il est suggéré que si cela est une première configuration de votre contrôleu Réglages Actuels + + UsageTrackerPlugin + + + Usage feedback + Retour d'utilisation + + + + Yes, count me in + Oui, comptez sur moi + + + + No, I will not help + Non, je ne souhaite pas aider + + + + Openpilot GCS has a function to collect limited anonymous information about the usage of the application itself and the OpenPilot hardware connected to it.<p>The intention is to not include anything that can be considered sensitive or a threat to the users integrity. The collected information will be sent using a secure protocol to an OpenPilot web service and stored in a database for later analysis and statistical purposes.<br>No information will be sold or given to any third party. The sole purpose is to collect statistics about the usage of our software and hardware to enable us to make things better for you.<p>The following things are collected:<ul><li>Bootloader version</li><li>Firmware version, tag and git hash</li><li>OP Hardware type, revision and mcu serial number</li><li>Selected configuration parameters</li><li>GCS version</li><li>Operating system version and architecture</li><li>Current local time</li></ul>The information is collected only at the time when a board is connecting to GCS.<p>It is possible to enable or disable this functionality in the general settings part of the options for the GCS application at any time.<p>We need your help, with your feedback we know where to improve things and what platforms are in use. This is a community project that depends on people being involved.<br>Thank You for helping us making things better and for supporting OpenPilot! + Openpilot GCS possède une fonction qui permet de collecter les informations de manière anonyme sur l'utilisation de l'application en elle-même ainsi que le matériel OpenPilot connecté dessus.<p>Il n'est pas question de collecter des informations sensibles ou pouvant représenter une menace pour l'intégrité des utilisateurs. Les informations collectées seront envoyées vers un site web OpenPilot en utilisant un protocole sécurisé et stockées dans une base de données pour une analyse et des statistiques ultérieures.<br>Aucune information ne sera vendue ou donnée à une quelconque tierce partie. Le seul but est de collecter des informations à propos de l'utilisation de notre logiciel / matériel pour nous permettre de l'améliorer.<p>Les éléments suivants sont collectés :<ul><li>Version bootloader</li><li>Version firmware, tag et git hash</li><li>Type de matériel OP, révision et numéro de série CPU</li><li>Paramètres de configuration sélectionnés</li><li>Version GCS</li><li>Système d'exploitation et architecture</li><li>Fuseau horaire</li></ul>Les informations sont collectées au moment de la connexion de la carte avec GCS.<p>Il est possible d'activer ou de désactiver cette fonctionnalité à tout moment dans le menu Options > Paramètres généraux de GCS.<p>Nous avons besoin de votre aide, avec votre participation nous connaîtrons où apporter des améliorations et quelle plateforme vous utilisez. C'est un projet communautaire qui dépend de l'implication des utilisateurs.<br>Merci de nous aider à rendre les choses meilleures et soutenir OpenPilot ! + + + + &Don't show this message again. + &Ne pas afficher ce message à nouveau. + + + + Unknown + Inconnu + +