1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +01:00

General cleaning up

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2635 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2011-01-31 10:16:06 +00:00 committed by pip
parent 9c313ebb7a
commit b13648da36
9 changed files with 633 additions and 633 deletions

View File

@ -1,6 +1,8 @@
TEMPLATE = lib TEMPLATE = lib
TARGET = PipXtreme TARGET = PipXtreme
QT += svg QT += svg
QT += opengl
include(../../openpilotgcsplugin.pri) include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/coreplugin/coreplugin.pri)

View File

@ -34,6 +34,9 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="toolTip">
<string>The PC port serial baud rate</string>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
@ -146,6 +149,9 @@
<property name="acceptDrops"> <property name="acceptDrops">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="toolTip">
<string>The modems serial number</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QLineEdit { <string notr="true">QLineEdit {
border: none; border: none;
@ -232,6 +238,9 @@
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
<property name="toolTip">
<string>The modems frequency band</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QLineEdit { <string notr="true">QLineEdit {
border: none; border: none;
@ -280,6 +289,9 @@
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
<property name="toolTip">
<string>The modems minimum allowed frequency</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QLineEdit { <string notr="true">QLineEdit {
border: none; border: none;
@ -328,6 +340,9 @@
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
<property name="toolTip">
<string>The modems maximum allowed frequency</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QLineEdit { <string notr="true">QLineEdit {
border: none; border: none;
@ -376,6 +391,9 @@
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
<property name="toolTip">
<string>The modems minimum frequency step size</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QLineEdit { <string notr="true">QLineEdit {
border: none; border: none;
@ -424,6 +442,9 @@
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
<property name="toolTip">
<string>The modems current state</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QLineEdit { <string notr="true">QLineEdit {
border: none; border: none;
@ -622,6 +643,35 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>RSSI (dBm)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QProgressBar" name="progressBar_RSSI">
<property name="minimum">
<number>-120</number>
</property>
<property name="maximum">
<number>-20</number>
</property>
<property name="value">
<number>-60</number>
</property>
<property name="textVisible">
<bool>true</bool>
</property>
<property name="format">
<string>%v</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -1,105 +1,109 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file pipxtremegadgetconfiguration.cpp * @file pipxtremegadgetconfiguration.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @{ * @{
*****************************************************************************/ *****************************************************************************/
/* /*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU General Public License along * 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., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "pipxtremegadgetconfiguration.h" #include "pipxtremegadgetconfiguration.h"
#include <qextserialport/src/qextserialport.h> #include <qextserialport/src/qextserialport.h>
/** /**
* Loads a saved configuration or defaults if non exist. * Loads a saved configuration or defaults if non exist.
* *
*/ */
PipXtremeGadgetConfiguration::PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) : PipXtremeGadgetConfiguration::PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent), IUAVGadgetConfiguration(classId, parent),
m_defaultPort("Unknown"), m_defaultPort("Unknown"),
m_defaultSpeed(BAUD57600), m_defaultSpeed(BAUD57600),
m_defaultDataBits(DATA_8), m_defaultDataBits(DATA_8),
m_defaultFlow(FLOW_OFF), m_defaultFlow(FLOW_OFF),
m_defaultParity(PAR_NONE), m_defaultParity(PAR_NONE),
m_defaultStopBits(STOP_1), m_defaultStopBits(STOP_1),
m_defaultTimeOut(5000) m_defaultTimeOut(5000)
{ {
//if a saved configuration exists load it //if a saved configuration exists load it
if (qSettings != 0) if (qSettings != 0)
{ {
BaudRateType speed; BaudRateType speed;
DataBitsType databits; DataBitsType databits;
FlowType flow; FlowType flow;
ParityType parity; ParityType parity;
StopBitsType stopbits; StopBitsType stopbits;
int ispeed = qSettings->value("defaultSpeed").toInt(); int ispeed = qSettings->value("defaultSpeed").toInt();
int idatabits = qSettings->value("defaultDataBits").toInt(); int idatabits = qSettings->value("defaultDataBits").toInt();
int iflow = qSettings->value("defaultFlow").toInt(); int iflow = qSettings->value("defaultFlow").toInt();
int iparity = qSettings->value("defaultParity").toInt(); int iparity = qSettings->value("defaultParity").toInt();
int istopbits = qSettings->value("defaultStopBits").toInt(); int istopbits = qSettings->value("defaultStopBits").toInt();
QString port = qSettings->value("defaultPort").toString(); QString port = qSettings->value("defaultPort").toString();
databits=(DataBitsType) idatabits; databits=(DataBitsType) idatabits;
flow=(FlowType)iflow; flow=(FlowType)iflow;
parity=(ParityType)iparity; parity=(ParityType)iparity;
stopbits=(StopBitsType)istopbits; stopbits=(StopBitsType)istopbits;
speed=(BaudRateType)ispeed; speed=(BaudRateType)ispeed;
m_defaultPort=port; m_defaultPort=port;
m_defaultSpeed=speed; m_defaultSpeed=speed;
m_defaultDataBits=databits; m_defaultDataBits=databits;
m_defaultFlow=flow; m_defaultFlow=flow;
m_defaultParity=parity; m_defaultParity=parity;
m_defaultStopBits=stopbits; m_defaultStopBits=stopbits;
} }
} }
/** PipXtremeGadgetConfiguration::~PipXtremeGadgetConfiguration()
* Clones a configuration. {
* }
*/
IUAVGadgetConfiguration *PipXtremeGadgetConfiguration::clone() /**
{ * Clones a configuration.
PipXtremeGadgetConfiguration *m = new PipXtremeGadgetConfiguration(this->classId()); *
*/
m->m_defaultSpeed = m_defaultSpeed; IUAVGadgetConfiguration *PipXtremeGadgetConfiguration::clone()
m->m_defaultDataBits = m_defaultDataBits; {
m->m_defaultFlow = m_defaultFlow; PipXtremeGadgetConfiguration *m = new PipXtremeGadgetConfiguration(this->classId());
m->m_defaultParity = m_defaultParity;
m->m_defaultStopBits = m_defaultStopBits; m->m_defaultSpeed = m_defaultSpeed;
m->m_defaultPort = m_defaultPort; m->m_defaultDataBits = m_defaultDataBits;
m->m_defaultFlow = m_defaultFlow;
return m; m->m_defaultParity = m_defaultParity;
} m->m_defaultStopBits = m_defaultStopBits;
m->m_defaultPort = m_defaultPort;
/**
* Saves a configuration. return m;
* }
*/
void PipXtremeGadgetConfiguration::saveConfig(QSettings* qSettings) const /**
{ * Saves a configuration.
qSettings->setValue("defaultSpeed", m_defaultSpeed); *
qSettings->setValue("defaultDataBits", m_defaultDataBits); */
qSettings->setValue("defaultFlow", m_defaultFlow); void PipXtremeGadgetConfiguration::saveConfig(QSettings* qSettings) const
qSettings->setValue("defaultParity", m_defaultParity); {
qSettings->setValue("defaultStopBits", m_defaultStopBits); qSettings->setValue("defaultSpeed", m_defaultSpeed);
qSettings->setValue("defaultPort", m_defaultPort); qSettings->setValue("defaultDataBits", m_defaultDataBits);
} qSettings->setValue("defaultFlow", m_defaultFlow);
qSettings->setValue("defaultParity", m_defaultParity);
qSettings->setValue("defaultStopBits", m_defaultStopBits);
qSettings->setValue("defaultPort", m_defaultPort);
}

View File

@ -1,72 +1,73 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file pipxtremegadgetconfiguration.h * @file pipxtremegadgetconfiguration.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @{ * @{
* @brief The YModem protocol serial uploader plugin * @brief The YModem protocol serial uploader plugin
*****************************************************************************/ *****************************************************************************/
/* /*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU General Public License along * 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., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef PIPXTREMEGADGETCONFIGURATION_H #ifndef PIPXTREMEGADGETCONFIGURATION_H
#define PIPXTREMEGADGETCONFIGURATION_H #define PIPXTREMEGADGETCONFIGURATION_H
#include <coreplugin/iuavgadgetconfiguration.h> #include <coreplugin/iuavgadgetconfiguration.h>
#include <qextserialport/src/qextserialport.h> #include <qextserialport/src/qextserialport.h>
using namespace Core; using namespace Core;
class PipXtremeGadgetConfiguration : public IUAVGadgetConfiguration class PipXtremeGadgetConfiguration : public IUAVGadgetConfiguration
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0); explicit PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
~PipXtremeGadgetConfiguration();
//set port configuration functions
void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;} //set port configuration functions
void setDataBits(DataBitsType databits) {m_defaultDataBits=databits;} void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;}
void setFlow(FlowType flow) {m_defaultFlow=flow;} void setDataBits(DataBitsType databits) {m_defaultDataBits=databits;}
void setParity(ParityType parity) {m_defaultParity=parity;} void setFlow(FlowType flow) {m_defaultFlow=flow;}
void setStopBits(StopBitsType stopbits) {m_defaultStopBits=stopbits;} void setParity(ParityType parity) {m_defaultParity=parity;}
void setPort(QString port){m_defaultPort=port;} void setStopBits(StopBitsType stopbits) {m_defaultStopBits=stopbits;}
void setTimeOut(long timeout){m_defaultTimeOut=timeout;} void setPort(QString port){m_defaultPort=port;}
void setTimeOut(long timeout){m_defaultTimeOut=timeout;}
//get port configuration functions
BaudRateType Speed() {return m_defaultSpeed;} //get port configuration functions
DataBitsType DataBits() {return m_defaultDataBits;} BaudRateType Speed() {return m_defaultSpeed;}
FlowType Flow() {return m_defaultFlow;} DataBitsType DataBits() {return m_defaultDataBits;}
ParityType Parity() {return m_defaultParity;} FlowType Flow() {return m_defaultFlow;}
StopBitsType StopBits() {return m_defaultStopBits;} ParityType Parity() {return m_defaultParity;}
QString Port(){return m_defaultPort;} StopBitsType StopBits() {return m_defaultStopBits;}
long TimeOut(){return m_defaultTimeOut;} QString Port(){return m_defaultPort;}
long TimeOut(){return m_defaultTimeOut;}
void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone();
private:
QString m_defaultPort; private:
BaudRateType m_defaultSpeed; QString m_defaultPort;
DataBitsType m_defaultDataBits; BaudRateType m_defaultSpeed;
FlowType m_defaultFlow; DataBitsType m_defaultDataBits;
ParityType m_defaultParity; FlowType m_defaultFlow;
StopBitsType m_defaultStopBits; ParityType m_defaultParity;
long m_defaultTimeOut; StopBitsType m_defaultStopBits;
}; long m_defaultTimeOut;
};
#endif
#endif

View File

@ -1,57 +1,57 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file pipxtremegadgetfactory.cpp * @file pipxtremegadgetfactory.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @{ * @{
*****************************************************************************/ *****************************************************************************/
/* /*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU General Public License along * 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., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "pipxtremegadgetfactory.h" #include "pipxtremegadgetfactory.h"
#include "pipxtremegadgetwidget.h" #include "pipxtremegadgetwidget.h"
#include "pipxtremegadget.h" #include "pipxtremegadget.h"
#include "pipxtremegadgetconfiguration.h" #include "pipxtremegadgetconfiguration.h"
#include "pipxtremegadgetoptionspage.h" #include "pipxtremegadgetoptionspage.h"
#include <coreplugin/iuavgadget.h> #include <coreplugin/iuavgadget.h>
PipXtremeGadgetFactory::PipXtremeGadgetFactory(QObject *parent) : PipXtremeGadgetFactory::PipXtremeGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("PipXtreme"), tr("PipXtreme Gadget"), parent) IUAVGadgetFactory(QString("PipXtreme"), tr("PipXtreme Gadget"), parent)
{ {
} }
PipXtremeGadgetFactory::~PipXtremeGadgetFactory() PipXtremeGadgetFactory::~PipXtremeGadgetFactory()
{ {
} }
Core::IUAVGadget* PipXtremeGadgetFactory::createGadget(QWidget *parent) Core::IUAVGadget* PipXtremeGadgetFactory::createGadget(QWidget *parent)
{ {
PipXtremeGadgetWidget* gadgetWidget = new PipXtremeGadgetWidget(parent); PipXtremeGadgetWidget *gadgetWidget = new PipXtremeGadgetWidget(parent);
return new PipXtremeGadget(QString("PipXtreme"), gadgetWidget, parent); return new PipXtremeGadget(QString("PipXtreme"), gadgetWidget, parent);
} }
IUAVGadgetConfiguration *PipXtremeGadgetFactory::createConfiguration(QSettings* qSettings) IUAVGadgetConfiguration * PipXtremeGadgetFactory::createConfiguration(QSettings *qSettings)
{ {
return new PipXtremeGadgetConfiguration(QString("PipXtreme"), qSettings); return new PipXtremeGadgetConfiguration(QString("PipXtreme"), qSettings);
} }
IOptionsPage *PipXtremeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage * PipXtremeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new PipXtremeGadgetOptionsPage(qobject_cast<PipXtremeGadgetConfiguration*>(config)); return new PipXtremeGadgetOptionsPage(qobject_cast<PipXtremeGadgetConfiguration *>(config));
} }

View File

@ -1,50 +1,51 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file pipxtremegadgetfactory.h * @file pipxtremegadgetfactory.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @{ * @{
*****************************************************************************/ *****************************************************************************/
/* /*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU General Public License along * 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., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef PIPXTREMEGADGETFACTORY_H #ifndef PIPXTREMEGADGETFACTORY_H
#define PIPXTREMEGADGETFACTORY_H #define PIPXTREMEGADGETFACTORY_H
#include <coreplugin/iuavgadgetfactory.h> #include <coreplugin/iuavgadgetfactory.h>
namespace Core { namespace Core {
class IUAVGadget; class IUAVGadget;
class IUAVGadgetFactory; class IUAVGadgetFactory;
} }
using namespace Core; using namespace Core;
class PipXtremeGadgetFactory : public Core::IUAVGadgetFactory class PipXtremeGadgetFactory : public Core::IUAVGadgetFactory
{ {
Q_OBJECT Q_OBJECT
public: public:
PipXtremeGadgetFactory(QObject *parent = 0); PipXtremeGadgetFactory(QObject *parent = 0);
~PipXtremeGadgetFactory(); ~PipXtremeGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget * createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings); IUAVGadgetConfiguration * createConfiguration(QSettings *qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage * createOptionsPage(IUAVGadgetConfiguration *config);
};
};
#endif
#endif

View File

@ -24,102 +24,97 @@
*/ */
#include <QDebug> #include <QDebug>
#include <QtOpenGL/QGLWidget>
#include "pipxtremegadgetwidget.h" #include "pipxtremegadgetwidget.h"
//#include <aggregation/aggregate.h> //#include <aggregation/aggregate.h>
#define SERIAL_PORT 1
#define USB_PORT 2
// ***************************************************************************************
// constructor // constructor
PipXtremeGadgetWidget::PipXtremeGadgetWidget(QWidget *parent) : QWidget(parent) PipXtremeGadgetWidget::PipXtremeGadgetWidget(QWidget *parent) :
QWidget(parent),
m_widget(NULL),
m_ioDevice(NULL)
{ {
m_config = new Ui_PipXtremeWidget(); m_widget = new Ui_PipXtremeWidget();
m_config->setupUi(this); m_widget->setupUi(this);
m_ioDevice = NULL; m_widget->comboBox_SerialBaudrate->clear();
m_widget->comboBox_SerialBaudrate->addItem("1200", 1200);
m_widget->comboBox_SerialBaudrate->addItem("2400", 2400);
m_widget->comboBox_SerialBaudrate->addItem("4800", 4800);
m_widget->comboBox_SerialBaudrate->addItem("9600", 9600);
m_widget->comboBox_SerialBaudrate->addItem("19200", 19200);
m_widget->comboBox_SerialBaudrate->addItem("38400", 38400);
m_widget->comboBox_SerialBaudrate->addItem("57600", 57600);
m_widget->comboBox_SerialBaudrate->addItem("115200", 115200);
// m_widget->comboBox_SerialBaudrate->addItem("230400", 230400);
// m_widget->comboBox_SerialBaudrate->addItem("460800", 460800);
// m_widget->comboBox_SerialBaudrate->addItem("921600", 921600);
m_widget->comboBox_SerialBaudrate->setCurrentIndex(m_widget->comboBox_SerialBaudrate->findText("57600"));
currentStep = IAP_STATE_READY; m_widget->comboBox_Mode->clear();
rescueStep = RESCUE_STEP0; m_widget->comboBox_Mode->addItem("Normal", 0);
resetOnly = false; m_widget->comboBox_Mode->addItem("Scan Spectrum", 1);
m_widget->comboBox_Mode->addItem("Calibrate Tx Carrier Frequency", 2);
m_widget->comboBox_Mode->addItem("Test Tx Spectrum", 3);
m_config->comboBox_Mode->clear(); m_widget->comboBox_SerialPortSpeed->clear();
m_config->comboBox_Mode->addItem("Normal", 0); for (int i = 0; i < m_widget->comboBox_SerialBaudrate->count(); i++)
m_config->comboBox_Mode->addItem("Scan Spectrum", 1); m_widget->comboBox_SerialPortSpeed->addItem(m_widget->comboBox_SerialBaudrate->itemText(i), m_widget->comboBox_SerialBaudrate->itemData(i));
m_config->comboBox_Mode->addItem("Tx Carrier Calibrate", 2); m_widget->comboBox_SerialPortSpeed->setCurrentIndex(m_widget->comboBox_SerialPortSpeed->findText("57600"));
m_config->comboBox_Mode->addItem("Tx Spectrum Test", 3);
m_config->comboBox_SerialBaudrate->clear(); m_widget->doubleSpinBox_Frequency->setSingleStep(0.00015625);
m_config->comboBox_SerialBaudrate->addItem("1200", 1200);
m_config->comboBox_SerialBaudrate->addItem("2400", 2400);
m_config->comboBox_SerialBaudrate->addItem("4800", 4800);
m_config->comboBox_SerialBaudrate->addItem("9600", 9600);
m_config->comboBox_SerialBaudrate->addItem("19200", 19200);
m_config->comboBox_SerialBaudrate->addItem("38400", 38400);
m_config->comboBox_SerialBaudrate->addItem("57600", 57600);
m_config->comboBox_SerialBaudrate->addItem("115200", 115200);
// m_config->comboBox_SerialBaudrate->addItem("230400", 230400);
// m_config->comboBox_SerialBaudrate->addItem("460800", 460800);
// m_config->comboBox_SerialBaudrate->addItem("921600", 921600);
m_config->comboBox_SerialBaudrate->setCurrentIndex(m_config->comboBox_SerialBaudrate->findText("57600"));
m_config->comboBox_SerialPortSpeed->clear(); m_widget->progressBar_RSSI->setMinimum(-120);
m_config->comboBox_SerialPortSpeed->addItem("1200", 1200); m_widget->progressBar_RSSI->setMaximum(-20);
m_config->comboBox_SerialPortSpeed->addItem("2400", 2400); m_widget->progressBar_RSSI->setValue(-80);
m_config->comboBox_SerialPortSpeed->addItem("4800", 4800);
m_config->comboBox_SerialPortSpeed->addItem("9600", 9600);
m_config->comboBox_SerialPortSpeed->addItem("19200", 19200);
m_config->comboBox_SerialPortSpeed->addItem("38400", 38400);
m_config->comboBox_SerialPortSpeed->addItem("57600", 57600);
m_config->comboBox_SerialPortSpeed->addItem("115200", 115200);
// m_config->comboBox_SerialPortSpeed->addItem("230400", 230400);
// m_config->comboBox_SerialPortSpeed->addItem("460800", 460800);
// m_config->comboBox_SerialPortSpeed->addItem("921600", 921600);
m_config->comboBox_SerialPortSpeed->setCurrentIndex(m_config->comboBox_SerialPortSpeed->findText("57600"));
m_config->doubleSpinBox_Frequency->setSingleStep(0.00015625); m_widget->graphicsView_Spectrum->setScene(new QGraphicsScene(this));
m_widget->graphicsView_Spectrum->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
m_config->graphicsView_Spectrum->setScene(new QGraphicsScene(this)); // m_widget->graphicsView_Spectrum->setViewport(new QWidget);
QGraphicsScene *spec_scene = m_config->graphicsView_Spectrum->scene(); m_widget->graphicsView_Spectrum->setCacheMode(QGraphicsView::CacheBackground);
m_widget->graphicsView_Spectrum->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
QGraphicsScene *spec_scene = m_widget->graphicsView_Spectrum->scene();
if (spec_scene) if (spec_scene)
{ {
spec_scene->setBackgroundBrush(Qt::black); spec_scene->setBackgroundBrush(QColor(80, 80, 80));
spec_scene->clear(); spec_scene->clear();
// spec_scene->addItem(m_background); // spec_scene->addItem(m_background);
// spec_scene->addItem(m_joystickEnd); // spec_scene->addItem(m_joystickEnd);
// spec_scene->setSceneRect(m_background->boundingRect()); // spec_scene->setSceneRect(m_background->boundingRect());
} }
m_config->pushButton_ScanSpectrum->setEnabled(false); m_widget->pushButton_ScanSpectrum->setEnabled(false);
// Listen to autopilot connection events QIcon rbi;
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); rbi.addFile(QString(":pipxtreme/images/view-refresh.svg"));
TelemetryManager *telMngr = pm->getObject<TelemetryManager>(); m_widget->refreshPorts->setIcon(rbi);
connect(telMngr, SIGNAL(myStart()), this, SLOT(onTelemetryStart()));
connect(telMngr, SIGNAL(myStop()), this, SLOT(onTelemetryStop()));
connect(telMngr, SIGNAL(connected()), this, SLOT(onTelemetryConnect()));
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onTelemetryDisconnect()));
// Note: remove listening to the connection manager, it overlaps with // Listen to telemetry connection events
// listening to the telemetry manager, we should only listen to one, not both. ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
if (pluginManager)
{
TelemetryManager *telemetryManager = pluginManager->getObject<TelemetryManager>();
if (telemetryManager)
{
connect(telemetryManager, SIGNAL(myStart()), this, SLOT(onTelemetryStart()));
connect(telemetryManager, SIGNAL(myStop()), this, SLOT(onTelemetryStop()));
connect(telemetryManager, SIGNAL(connected()), this, SLOT(onTelemetryConnect()));
connect(telemetryManager, SIGNAL(disconnected()), this, SLOT(onTelemetryDisconnect()));
}
}
// Also listen to disconnect actions from the user: getPorts();
// Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
// connect(cm, SIGNAL(deviceDisconnected()), this, SLOT(onModemDisconnect()));
// int opened = rawHidHandle.open(10, 0x20A0, 0x4117, 0xFF9C, 0x0001); connect(m_widget->connectButton, SIGNAL(clicked()), this, SLOT(connectDisconnect()));
// rawHidPlugin = new RawHIDPlugin(); connect(m_widget->refreshPorts, SIGNAL(clicked()), this, SLOT(getPorts()));
connect(m_config->connectButton, SIGNAL(clicked()), this, SLOT(connectDisconnect()));
getPorts();
QIcon rbi;
rbi.addFile(QString(":pipxtreme/images/view-refresh.svg"));
m_config->refreshPorts->setIcon(rbi);
connect(m_config->refreshPorts, SIGNAL(clicked()), this, SLOT(getPorts()));
if (m_ioDevice)
connect(m_ioDevice, SIGNAL(readyRead()), this, SLOT(processInputStream()));
// delay::msleep(600); // just for pips reference // delay::msleep(600); // just for pips reference
} }
@ -127,16 +122,18 @@ PipXtremeGadgetWidget::PipXtremeGadgetWidget(QWidget *parent) : QWidget(parent)
// destructor .. this never gets called :( // destructor .. this never gets called :(
PipXtremeGadgetWidget::~PipXtremeGadgetWidget() PipXtremeGadgetWidget::~PipXtremeGadgetWidget()
{ {
disconnect(false); disconnectPort(false);
} }
// ***************************************************************************************
void PipXtremeGadgetWidget::resizeEvent(QResizeEvent *event) void PipXtremeGadgetWidget::resizeEvent(QResizeEvent *event)
{ {
if (m_config) if (m_widget)
{ {
if (m_config->graphicsView_Spectrum) if (m_widget->graphicsView_Spectrum)
{ {
QGraphicsScene *spec_scene = m_config->graphicsView_Spectrum->scene(); QGraphicsScene *spec_scene = m_widget->graphicsView_Spectrum->scene();
if (spec_scene) if (spec_scene)
{ {
// spec_scene->setSceneRect(QRect(QPoint(0, 0), event->size())); // spec_scene->setSceneRect(QRect(QPoint(0, 0), event->size()));
@ -148,36 +145,66 @@ void PipXtremeGadgetWidget::resizeEvent(QResizeEvent *event)
// PipXtremeGadgetWidget::resizeEvent(event); // PipXtremeGadgetWidget::resizeEvent(event);
} }
// ***************************************************************************************
void PipXtremeGadgetWidget::onComboBoxPorts_currentIndexChanged(int index)
{
if (index < 0)
{
m_widget->comboBox_SerialBaudrate->setEnabled(false);
return;
}
int type = m_widget->comboBox_Ports->itemData(index).toInt();
m_widget->comboBox_SerialBaudrate->setEnabled(type == SERIAL_PORT);
}
// ***************************************************************************************
QString PipXtremeGadgetWidget::getSerialPortDevice(const QString &friendName)
{
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
foreach (QextPortInfo port, ports)
{
#ifdef Q_OS_WIN
if (port.friendName == friendName)
return port.portName;
#else
if (port.friendName == friendName)
return port.physName;
#endif
}
return "";
}
bool sortSerialPorts(const QextPortInfo &s1, const QextPortInfo &s2) bool sortSerialPorts(const QextPortInfo &s1, const QextPortInfo &s2)
{ {
return (s1.portName < s2.portName); return (s1.portName < s2.portName);
} }
// ***************************************************************************************
void PipXtremeGadgetWidget::getPorts() void PipXtremeGadgetWidget::getPorts()
{ {
QStringList list; QStringList list;
// m_config->refreshPorts->setEnabled(false); disconnect(m_widget->comboBox_Ports, 0, 0, 0);
// m_config->comboBox_Ports->setEnabled(false);
m_config->comboBox_Ports->clear(); m_widget->comboBox_Ports->clear();
// ******************************** // ********************************
// Populate the telemetry combo box with serial ports // Populate the telemetry combo box with serial ports
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); QList<QextPortInfo> serial_ports = QextSerialEnumerator::getPorts();
qSort(ports.begin(), ports.end(), sortSerialPorts); qSort(serial_ports.begin(), serial_ports.end(), sortSerialPorts);
foreach (QextPortInfo port, ports) foreach (QextPortInfo port, serial_ports)
list.append(port.friendName); list.append(port.friendName);
for (int i = 0; i < list.count(); i++) for (int i = 0; i < list.count(); i++)
m_config->comboBox_Ports->addItem(list.at(i), 0); m_widget->comboBox_Ports->addItem(list.at(i), SERIAL_PORT);
// m_config->comboBox_Ports->addItems(list);
// ******************************** // ********************************
// Populate the telemetry combo box with usb ports // Populate the telemetry combo box with usb ports
@ -193,10 +220,10 @@ void PipXtremeGadgetWidget::getPorts()
for (int i = 0; i < opened; i++) for (int i = 0; i < opened; i++)
usb_ports.append(rawHidHandle->getserial(i)); usb_ports.append(rawHidHandle->getserial(i));
for (int i = 0; i < usb_ports.count(); i++) qSort(usb_ports.begin(), usb_ports.end());
m_config->comboBox_Ports->addItem(usb_ports.at(i), 1);
// m_config->comboBox_Ports->addItems(usb_ports); for (int i = 0; i < usb_ports.count(); i++)
m_widget->comboBox_Ports->addItem(usb_ports.at(i), USB_PORT);
} }
delete rawHidHandle; delete rawHidHandle;
@ -204,43 +231,36 @@ void PipXtremeGadgetWidget::getPorts()
// ******************************** // ********************************
// m_config->refreshPorts->setEnabled(true); connect(m_widget->comboBox_Ports, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxPorts_currentIndexChanged(int)));
// m_config->comboBox_Ports->setEnabled(true);
onComboBoxPorts_currentIndexChanged(m_widget->comboBox_Ports->currentIndex());
// ********************************
} }
QString PipXtremeGadgetWidget::getPortDevice(const QString &friendName) // ***************************************************************************************
{
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
foreach (QextPortInfo port, ports)
{
#ifdef Q_OS_WIN
if (port.friendName == friendName)
return port.portName;
#else
if (port.friendName == friendName)
return port.physName;
#endif
}
return "";
}
// *************************************************************************
void PipXtremeGadgetWidget::onTelemetryStart() void PipXtremeGadgetWidget::onTelemetryStart()
{ {
m_config->connectButton->setEnabled(false); setEnabled(false);
m_config->comboBox_Ports->setEnabled(false);
// m_widget->connectButton->setEnabled(false);
// m_widget->comboBox_Ports->setEnabled(false);
// m_widget->refreshPorts->setEnabled(false);
// m_widget->comboBox_SerialBaudrate->setEnabled(false);
} }
void PipXtremeGadgetWidget::onTelemetryStop() void PipXtremeGadgetWidget::onTelemetryStop()
{ {
m_config->connectButton->setEnabled(true); setEnabled(true);
m_config->comboBox_Ports->setEnabled(true);
// m_widget->connectButton->setEnabled(true);
// m_widget->comboBox_Ports->setEnabled(true);
// m_widget->refreshPorts->setEnabled(true);
// m_widget->comboBox_SerialBaudrate->setEnabled(true);
} }
// ************************************************************************* // ***************************************************************************************
void PipXtremeGadgetWidget::onTelemetryConnect() void PipXtremeGadgetWidget::onTelemetryConnect()
{ {
@ -250,44 +270,28 @@ void PipXtremeGadgetWidget::onTelemetryDisconnect()
{ {
} }
// ************************************************************************* // ***************************************************************************************
void PipXtremeGadgetWidget::onModemConnect() void PipXtremeGadgetWidget::disableTelemetry()
{ { // Suspend telemetry & polling
m_config->connectButton->setText(tr(" Disconnect "));
m_config->comboBox_Ports->setEnabled(false);
m_config->pushButton_ScanSpectrum->setEnabled(true);
}
void PipXtremeGadgetWidget::onModemDisconnect()
{
m_config->connectButton->setText(tr(" Connect "));
m_config->comboBox_Ports->setEnabled(true);
m_config->pushButton_ScanSpectrum->setEnabled(false);
}
// *************************************************************************
void PipXtremeGadgetWidget::suspendTelemetry()
{
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager(); Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
if (!cm) return; if (!cm) return;
// Suspend telemety & polling
cm->disconnectDevice(); cm->disconnectDevice();
cm->suspendPolling(); cm->suspendPolling();
} }
void PipXtremeGadgetWidget::restartTelemetryPolling() void PipXtremeGadgetWidget::enableTelemetry()
{ { // Restart the polling thread
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager(); Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
if (!cm) return; if (!cm) return;
// Restart the polling thread
cm->resumePolling(); cm->resumePolling();
} }
// ************************************************************************* // ***************************************************************************************
void PipXtremeGadgetWidget::processOutputStream() void PipXtremeGadgetWidget::processOutputStream()
{ {
@ -297,26 +301,45 @@ void PipXtremeGadgetWidget::processOutputStream()
if (!m_ioDevice->isOpen()) if (!m_ioDevice->isOpen())
return; return;
// if (m_ioDevice->bytesToWrite() < TX_BUFFER_SIZE ) // if (m_ioDevice->bytesToWrite() < TX_BUFFER_SIZE )
{ {
// m_ioDevice->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH); // m_ioDevice->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH);
} }
} }
void PipXtremeGadgetWidget::processInputStream() void PipXtremeGadgetWidget::processInputStream()
{ {
while (m_ioDevice && m_ioDevice->bytesAvailable() > 0) while (m_ioDevice)
{ {
quint8 tmp; quint8 buf;
m_ioDevice->read((char*)&tmp, 1);
// processInputByte(tmp); if (!m_ioDevice->isOpen())
break;
qint64 bytes_available = m_ioDevice->bytesAvailable();
if (bytes_available <= 0)
break;
qint64 bytes_read = m_ioDevice->read((char *)&buf, sizeof(buf));
if (bytes_read <= 0)
break;
processInputBytes(&buf, sizeof(buf));
} }
} }
// ************************************************************************* void PipXtremeGadgetWidget::processInputBytes(quint8 *buf, int count)
{
if (!buf || count <= 0)
return;
void PipXtremeGadgetWidget::disconnect(bool resume_polling)
}
// ***************************************************************************************
void PipXtremeGadgetWidget::disconnectPort(bool enable_telemetry)
{ // disconnect the comms port { // disconnect the comms port
if (!m_ioDevice) if (!m_ioDevice)
@ -324,56 +347,54 @@ void PipXtremeGadgetWidget::disconnect(bool resume_polling)
m_ioDevice->close(); m_ioDevice->close();
disconnect(m_ioDevice, 0, 0, 0);
delete m_ioDevice; delete m_ioDevice;
m_ioDevice = NULL; m_ioDevice = NULL;
m_config->connectButton->setText("Connect"); m_widget->connectButton->setText("Connect");
m_config->comboBox_SerialBaudrate->setEnabled(true); m_widget->comboBox_SerialBaudrate->setEnabled(true);
m_config->comboBox_Ports->setEnabled(true); m_widget->comboBox_Ports->setEnabled(true);
m_config->refreshPorts->setEnabled(true); m_widget->refreshPorts->setEnabled(true);
m_widget->pushButton_ScanSpectrum->setEnabled(false);
restartTelemetryPolling(); if (enable_telemetry)
enableTelemetry();
} }
void PipXtremeGadgetWidget::connectDisconnect() void PipXtremeGadgetWidget::connectPort()
{ { // connect the comms port
if (m_ioDevice)
{ // disconnect
disconnect(true);
return;
}
// **************** disconnectPort(true);
// connect
int device_idx = m_config->comboBox_Ports->currentIndex(); int device_idx = m_widget->comboBox_Ports->currentIndex();
if (device_idx < 0) if (device_idx < 0)
return; return;
QString device_str = m_config->comboBox_Ports->currentText().trimmed(); QString device_str = m_widget->comboBox_Ports->currentText().trimmed();
if (device_str.isEmpty()) if (device_str.isEmpty())
return; return;
int type = m_config->comboBox_Ports->itemData(device_idx).toInt(); int type = m_widget->comboBox_Ports->itemData(device_idx).toInt();
// qDebug() << QString::number(type) << ": " << device_str; // qDebug() << QString::number(type) << ": " << device_str;
// Suspend telemety & polling in case it is not done yet // Suspend telemety & polling in case it is not done yet
suspendTelemetry(); disableTelemetry();
switch (type) switch (type)
{ {
case 0: // serial port case SERIAL_PORT: // serial port
{ {
QString str = getPortDevice(device_str); QString str = getSerialPortDevice(device_str);
if (str.isEmpty()) if (str.isEmpty())
break; break;
int br_idx = m_config->comboBox_SerialBaudrate->currentIndex(); int br_idx = m_widget->comboBox_SerialBaudrate->currentIndex();
if (br_idx < 0) if (br_idx < 0)
break; break;
int baudrate = m_config->comboBox_SerialBaudrate->itemData(br_idx).toInt(); int baudrate = m_widget->comboBox_SerialBaudrate->itemData(br_idx).toInt();
BaudRateType bdt = BAUD57600; BaudRateType bdt = BAUD57600;
switch (baudrate) switch (baudrate)
@ -398,7 +419,8 @@ void PipXtremeGadgetWidget::connectDisconnect()
settings.FlowControl = FLOW_OFF; settings.FlowControl = FLOW_OFF;
settings.Timeout_Millisec = 500; settings.Timeout_Millisec = 500;
QextSerialPort *serial_dev = new QextSerialPort(str, settings, QextSerialPort::Polling); // QextSerialPort *serial_dev = new QextSerialPort(str, settings, QextSerialPort::Polling);
QextSerialPort *serial_dev = new QextSerialPort(str, settings);
if (!serial_dev) if (!serial_dev)
break; break;
@ -409,15 +431,10 @@ void PipXtremeGadgetWidget::connectDisconnect()
} }
m_ioDevice = serial_dev; m_ioDevice = serial_dev;
break;
m_config->connectButton->setText("Disconnect");
m_config->comboBox_SerialBaudrate->setEnabled(false);
m_config->comboBox_Ports->setEnabled(false);
m_config->refreshPorts->setEnabled(false);
return;
} }
case 1: // USB port case USB_PORT: // USB port
{ {
RawHID *usb_dev = new RawHID(device_str); RawHID *usb_dev = new RawHID(device_str);
if (!usb_dev) if (!usb_dev)
@ -430,104 +447,37 @@ void PipXtremeGadgetWidget::connectDisconnect()
} }
m_ioDevice = usb_dev; m_ioDevice = usb_dev;
break;
m_config->connectButton->setText("Disconnect");
m_config->comboBox_SerialBaudrate->setEnabled(false);
m_config->comboBox_Ports->setEnabled(false);
m_config->refreshPorts->setEnabled(false);
return;
} }
default: // unknown default: // unknown port type
break; break;
} }
restartTelemetryPolling(); if (!m_ioDevice)
{ // failed to connect
enableTelemetry();
}
else
{ // connected OK
m_widget->connectButton->setText("Disconnect");
m_widget->comboBox_SerialBaudrate->setEnabled(false);
m_widget->comboBox_Ports->setEnabled(false);
m_widget->refreshPorts->setEnabled(false);
m_widget->pushButton_ScanSpectrum->setEnabled(true);
connect(m_ioDevice, SIGNAL(readyRead()), this, SLOT(processInputStream()));
}
} }
// ************************************************************************* // ***************************************************************************************
// Ask the modem to go into API mode void PipXtremeGadgetWidget::connectDisconnect()
void PipXtremeGadgetWidget::goToAPIMode(UAVObject* callerObj, bool success)
{ {
Q_UNUSED(callerObj); if (m_ioDevice)
/* disconnectPort(true); // disconnect
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); else
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); connectPort(); // connect
UAVObject *fwIAP = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("FirmwareIAPObj")));
switch (currentStep)
{
case IAP_STATE_READY:
getPorts(); // Useful in case a new serial port appeared since the initial list,
// otherwise we won't find it when we stop the board.
// The board is running, send the 1st IAP Reset order:
fwIAP->getField("Command")->setValue("1122");
connect(fwIAP,SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToAPIMode(UAVObject*, bool)));
currentStep = IAP_STATE_STEP_1;
fwIAP->updated();
break;
case IAP_STATE_STEP_1:
if (!success)
{
currentStep = IAP_STATE_READY;
disconnect(fwIAP, SIGNAL(transactionCompleted(UAVObject*,bool)),this,SLOT(goToAPIMode(UAVObject*, bool)));
break;
}
delay::msleep(600);
fwIAP->getField("Command")->setValue("2233");
currentStep = IAP_STATE_READY;
fwIAP->updated();
break;
}
*/
}
// Tells the system to boot (from Bootloader state)
void PipXtremeGadgetWidget::systemBoot()
{
/*
// Suspend telemety & polling in case it is not done yet
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
cm->disconnectDevice();
cm->suspendPolling();
QString devName = m_config->comboBox_Ports->currentText();
repaint();
if (!dfu)
{
if (devName == "USB")
dfu = new DFUObject(DFU_DEBUG, false, QString());
else
dfu = new DFUObject(DFU_DEBUG,true,getPortDevice(devName));
}
dfu->AbortOperation();
if (!dfu->enterDFU(0))
{
delete dfu;
dfu = NULL;
return;
}
dfu->JumpToApp();
// Restart the polling thread
cm->resumePolling();
m_config->comboBox_Ports->setEnabled(true);
if (currentStep == IAP_STATE_BOOTLOADER )
{
}
currentStep = IAP_STATE_READY;
delete dfu; // Frees up the USB/Serial port too
dfu = NULL;
*/
} }
// *************************************************************************************** // ***************************************************************************************
@ -535,9 +485,10 @@ void PipXtremeGadgetWidget::systemBoot()
// Shows a message box with an error string. // Shows a message box with an error string.
void PipXtremeGadgetWidget::error(QString errorString, int errorNumber) void PipXtremeGadgetWidget::error(QString errorString, int errorNumber)
{ {
Q_UNUSED(errorNumber);
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical); msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(errorString + " [" + QString::number(errorNumber) + "]"); msgBox.setText(errorString + " [" + QString::number(errorNumber) + "]");
msgBox.exec(); msgBox.exec();
} }
// ***************************************************************************************

View File

@ -116,49 +116,42 @@ public:
~PipXtremeGadgetWidget(); ~PipXtremeGadgetWidget();
typedef enum { IAP_STATE_READY, IAP_STATE_STEP_1} IAPStep; typedef enum { IAP_STATE_READY, IAP_STATE_STEP_1} IAPStep;
typedef enum { RESCUE_STEP0, RESCUE_STEP1, RESCUE_STEP2, RESCUE_STEP3, RESCUE_POWER1, RESCUE_POWER2, RESCUE_DETECT } RescueStep;
public slots: public slots:
void onTelemetryStart(); void onTelemetryStart();
void onTelemetryStop(); void onTelemetryStop();
void onTelemetryConnect(); void onTelemetryConnect();
void onTelemetryDisconnect(); void onTelemetryDisconnect();
void onModemConnect(); void onComboBoxPorts_currentIndexChanged(int index);
void onModemDisconnect();
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
private: private:
Ui_PipXtremeWidget *m_config; Ui_PipXtremeWidget *m_widget;
IAPStep currentStep; QIODevice *m_ioDevice;
RescueStep rescueStep;
bool resetOnly;
pjrc_rawhid rawHidHandle; QString getSerialPortDevice(const QString &friendName);
// RawHIDPlugin *rawHidPlugin;
// currently connected QIODevice void disableTelemetry();
QIODevice *m_ioDevice; void enableTelemetry();
QString getPortDevice(const QString &friendName);
void suspendTelemetry();
void restartTelemetryPolling();
void processOutputStream(); void processOutputStream();
void processInputStream(); void processInputStream();
void disconnect(bool resume_polling); void disconnectPort(bool enable_telemetry);
void connectPort();
void processInputBytes(quint8 *buf, int count);
private slots: private slots:
void connectDisconnect(); void connectDisconnect();
void error(QString errorString,int errorNumber); void error(QString errorString, int errorNumber);
void goToAPIMode(UAVObject* = NULL, bool = false);
void systemBoot();
void getPorts(); void getPorts();
}; };
#endif #endif

View File

@ -1,61 +1,59 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file pipxtremeplugin.cpp * @file pipxtremeplugin.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @{ * @{
*****************************************************************************/ *****************************************************************************/
/* /*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU General Public License along * 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., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "pipxtremeplugin.h" #include "pipxtremeplugin.h"
#include "pipxtremegadgetfactory.h" #include "pipxtremegadgetfactory.h"
#include <QtPlugin> #include <QtPlugin>
#include <QStringList> #include <QStringList>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
PipXtremePlugin::PipXtremePlugin() PipXtremePlugin::PipXtremePlugin()
{ {
// Do nothing }
}
PipXtremePlugin::~PipXtremePlugin()
PipXtremePlugin::~PipXtremePlugin() {
{ }
// Do nothing
} bool PipXtremePlugin::initialize(const QStringList& args, QString *errMsg)
{
bool PipXtremePlugin::initialize(const QStringList& args, QString *errMsg) Q_UNUSED(args);
{ Q_UNUSED(errMsg);
Q_UNUSED(args); mf = new PipXtremeGadgetFactory(this);
Q_UNUSED(errMsg); addAutoReleasedObject(mf);
mf = new PipXtremeGadgetFactory(this); return true;
addAutoReleasedObject(mf); }
return true;
} void PipXtremePlugin::extensionsInitialized()
{
void PipXtremePlugin::extensionsInitialized() // Do nothing
{ }
// Do nothing
} void PipXtremePlugin::shutdown()
{
void PipXtremePlugin::shutdown() // Do nothing
{ }
// Do nothing Q_EXPORT_PLUGIN(PipXtremePlugin)
}
Q_EXPORT_PLUGIN(PipXtremePlugin)