mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-19 09: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:
parent
9c313ebb7a
commit
b13648da36
@ -1,6 +1,8 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = PipXtreme
|
||||
|
||||
QT += svg
|
||||
QT += opengl
|
||||
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
|
@ -34,6 +34,9 @@
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The PC port serial baud rate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
@ -146,6 +149,9 @@
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The modems serial number</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit {
|
||||
border: none;
|
||||
@ -232,6 +238,9 @@
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The modems frequency band</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit {
|
||||
border: none;
|
||||
@ -280,6 +289,9 @@
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The modems minimum allowed frequency</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit {
|
||||
border: none;
|
||||
@ -328,6 +340,9 @@
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The modems maximum allowed frequency</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit {
|
||||
border: none;
|
||||
@ -376,6 +391,9 @@
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The modems minimum frequency step size</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit {
|
||||
border: none;
|
||||
@ -424,6 +442,9 @@
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The modems current state</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit {
|
||||
border: none;
|
||||
@ -622,6 +643,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -1,105 +1,109 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file pipxtremegadgetconfiguration.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @{
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "pipxtremegadgetconfiguration.h"
|
||||
#include <qextserialport/src/qextserialport.h>
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
*
|
||||
*/
|
||||
PipXtremeGadgetConfiguration::PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_defaultPort("Unknown"),
|
||||
m_defaultSpeed(BAUD57600),
|
||||
m_defaultDataBits(DATA_8),
|
||||
m_defaultFlow(FLOW_OFF),
|
||||
m_defaultParity(PAR_NONE),
|
||||
m_defaultStopBits(STOP_1),
|
||||
m_defaultTimeOut(5000)
|
||||
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if (qSettings != 0)
|
||||
{
|
||||
BaudRateType speed;
|
||||
DataBitsType databits;
|
||||
FlowType flow;
|
||||
ParityType parity;
|
||||
StopBitsType stopbits;
|
||||
|
||||
int ispeed = qSettings->value("defaultSpeed").toInt();
|
||||
int idatabits = qSettings->value("defaultDataBits").toInt();
|
||||
int iflow = qSettings->value("defaultFlow").toInt();
|
||||
int iparity = qSettings->value("defaultParity").toInt();
|
||||
int istopbits = qSettings->value("defaultStopBits").toInt();
|
||||
QString port = qSettings->value("defaultPort").toString();
|
||||
|
||||
databits=(DataBitsType) idatabits;
|
||||
flow=(FlowType)iflow;
|
||||
parity=(ParityType)iparity;
|
||||
stopbits=(StopBitsType)istopbits;
|
||||
speed=(BaudRateType)ispeed;
|
||||
|
||||
m_defaultPort=port;
|
||||
m_defaultSpeed=speed;
|
||||
m_defaultDataBits=databits;
|
||||
m_defaultFlow=flow;
|
||||
m_defaultParity=parity;
|
||||
m_defaultStopBits=stopbits;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a configuration.
|
||||
*
|
||||
*/
|
||||
IUAVGadgetConfiguration *PipXtremeGadgetConfiguration::clone()
|
||||
{
|
||||
PipXtremeGadgetConfiguration *m = new PipXtremeGadgetConfiguration(this->classId());
|
||||
|
||||
m->m_defaultSpeed = m_defaultSpeed;
|
||||
m->m_defaultDataBits = m_defaultDataBits;
|
||||
m->m_defaultFlow = m_defaultFlow;
|
||||
m->m_defaultParity = m_defaultParity;
|
||||
m->m_defaultStopBits = m_defaultStopBits;
|
||||
m->m_defaultPort = m_defaultPort;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
void PipXtremeGadgetConfiguration::saveConfig(QSettings* qSettings) const
|
||||
{
|
||||
qSettings->setValue("defaultSpeed", m_defaultSpeed);
|
||||
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);
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file pipxtremegadgetconfiguration.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @{
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "pipxtremegadgetconfiguration.h"
|
||||
#include <qextserialport/src/qextserialport.h>
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
*
|
||||
*/
|
||||
PipXtremeGadgetConfiguration::PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_defaultPort("Unknown"),
|
||||
m_defaultSpeed(BAUD57600),
|
||||
m_defaultDataBits(DATA_8),
|
||||
m_defaultFlow(FLOW_OFF),
|
||||
m_defaultParity(PAR_NONE),
|
||||
m_defaultStopBits(STOP_1),
|
||||
m_defaultTimeOut(5000)
|
||||
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if (qSettings != 0)
|
||||
{
|
||||
BaudRateType speed;
|
||||
DataBitsType databits;
|
||||
FlowType flow;
|
||||
ParityType parity;
|
||||
StopBitsType stopbits;
|
||||
|
||||
int ispeed = qSettings->value("defaultSpeed").toInt();
|
||||
int idatabits = qSettings->value("defaultDataBits").toInt();
|
||||
int iflow = qSettings->value("defaultFlow").toInt();
|
||||
int iparity = qSettings->value("defaultParity").toInt();
|
||||
int istopbits = qSettings->value("defaultStopBits").toInt();
|
||||
QString port = qSettings->value("defaultPort").toString();
|
||||
|
||||
databits=(DataBitsType) idatabits;
|
||||
flow=(FlowType)iflow;
|
||||
parity=(ParityType)iparity;
|
||||
stopbits=(StopBitsType)istopbits;
|
||||
speed=(BaudRateType)ispeed;
|
||||
|
||||
m_defaultPort=port;
|
||||
m_defaultSpeed=speed;
|
||||
m_defaultDataBits=databits;
|
||||
m_defaultFlow=flow;
|
||||
m_defaultParity=parity;
|
||||
m_defaultStopBits=stopbits;
|
||||
}
|
||||
}
|
||||
|
||||
PipXtremeGadgetConfiguration::~PipXtremeGadgetConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a configuration.
|
||||
*
|
||||
*/
|
||||
IUAVGadgetConfiguration *PipXtremeGadgetConfiguration::clone()
|
||||
{
|
||||
PipXtremeGadgetConfiguration *m = new PipXtremeGadgetConfiguration(this->classId());
|
||||
|
||||
m->m_defaultSpeed = m_defaultSpeed;
|
||||
m->m_defaultDataBits = m_defaultDataBits;
|
||||
m->m_defaultFlow = m_defaultFlow;
|
||||
m->m_defaultParity = m_defaultParity;
|
||||
m->m_defaultStopBits = m_defaultStopBits;
|
||||
m->m_defaultPort = m_defaultPort;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
void PipXtremeGadgetConfiguration::saveConfig(QSettings* qSettings) const
|
||||
{
|
||||
qSettings->setValue("defaultSpeed", m_defaultSpeed);
|
||||
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);
|
||||
}
|
||||
|
@ -1,72 +1,73 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file pipxtremegadgetconfiguration.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @{
|
||||
* @brief The YModem protocol serial uploader plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 PIPXTREMEGADGETCONFIGURATION_H
|
||||
#define PIPXTREMEGADGETCONFIGURATION_H
|
||||
|
||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||
#include <qextserialport/src/qextserialport.h>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class PipXtremeGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
//set port configuration functions
|
||||
void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;}
|
||||
void setDataBits(DataBitsType databits) {m_defaultDataBits=databits;}
|
||||
void setFlow(FlowType flow) {m_defaultFlow=flow;}
|
||||
void setParity(ParityType parity) {m_defaultParity=parity;}
|
||||
void setStopBits(StopBitsType stopbits) {m_defaultStopBits=stopbits;}
|
||||
void setPort(QString port){m_defaultPort=port;}
|
||||
void setTimeOut(long timeout){m_defaultTimeOut=timeout;}
|
||||
|
||||
//get port configuration functions
|
||||
BaudRateType Speed() {return m_defaultSpeed;}
|
||||
DataBitsType DataBits() {return m_defaultDataBits;}
|
||||
FlowType Flow() {return m_defaultFlow;}
|
||||
ParityType Parity() {return m_defaultParity;}
|
||||
StopBitsType StopBits() {return m_defaultStopBits;}
|
||||
QString Port(){return m_defaultPort;}
|
||||
long TimeOut(){return m_defaultTimeOut;}
|
||||
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
QString m_defaultPort;
|
||||
BaudRateType m_defaultSpeed;
|
||||
DataBitsType m_defaultDataBits;
|
||||
FlowType m_defaultFlow;
|
||||
ParityType m_defaultParity;
|
||||
StopBitsType m_defaultStopBits;
|
||||
long m_defaultTimeOut;
|
||||
};
|
||||
|
||||
#endif
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file pipxtremegadgetconfiguration.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @{
|
||||
* @brief The YModem protocol serial uploader plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 PIPXTREMEGADGETCONFIGURATION_H
|
||||
#define PIPXTREMEGADGETCONFIGURATION_H
|
||||
|
||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||
#include <qextserialport/src/qextserialport.h>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class PipXtremeGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PipXtremeGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
~PipXtremeGadgetConfiguration();
|
||||
|
||||
//set port configuration functions
|
||||
void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;}
|
||||
void setDataBits(DataBitsType databits) {m_defaultDataBits=databits;}
|
||||
void setFlow(FlowType flow) {m_defaultFlow=flow;}
|
||||
void setParity(ParityType parity) {m_defaultParity=parity;}
|
||||
void setStopBits(StopBitsType stopbits) {m_defaultStopBits=stopbits;}
|
||||
void setPort(QString port){m_defaultPort=port;}
|
||||
void setTimeOut(long timeout){m_defaultTimeOut=timeout;}
|
||||
|
||||
//get port configuration functions
|
||||
BaudRateType Speed() {return m_defaultSpeed;}
|
||||
DataBitsType DataBits() {return m_defaultDataBits;}
|
||||
FlowType Flow() {return m_defaultFlow;}
|
||||
ParityType Parity() {return m_defaultParity;}
|
||||
StopBitsType StopBits() {return m_defaultStopBits;}
|
||||
QString Port(){return m_defaultPort;}
|
||||
long TimeOut(){return m_defaultTimeOut;}
|
||||
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
QString m_defaultPort;
|
||||
BaudRateType m_defaultSpeed;
|
||||
DataBitsType m_defaultDataBits;
|
||||
FlowType m_defaultFlow;
|
||||
ParityType m_defaultParity;
|
||||
StopBitsType m_defaultStopBits;
|
||||
long m_defaultTimeOut;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,57 +1,57 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file pipxtremegadgetfactory.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @{
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "pipxtremegadgetfactory.h"
|
||||
#include "pipxtremegadgetwidget.h"
|
||||
#include "pipxtremegadget.h"
|
||||
#include "pipxtremegadgetconfiguration.h"
|
||||
#include "pipxtremegadgetoptionspage.h"
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
PipXtremeGadgetFactory::PipXtremeGadgetFactory(QObject *parent) :
|
||||
IUAVGadgetFactory(QString("PipXtreme"), tr("PipXtreme Gadget"), parent)
|
||||
{
|
||||
}
|
||||
|
||||
PipXtremeGadgetFactory::~PipXtremeGadgetFactory()
|
||||
{
|
||||
}
|
||||
|
||||
Core::IUAVGadget* PipXtremeGadgetFactory::createGadget(QWidget *parent)
|
||||
{
|
||||
PipXtremeGadgetWidget* gadgetWidget = new PipXtremeGadgetWidget(parent);
|
||||
return new PipXtremeGadget(QString("PipXtreme"), gadgetWidget, parent);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *PipXtremeGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new PipXtremeGadgetConfiguration(QString("PipXtreme"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *PipXtremeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new PipXtremeGadgetOptionsPage(qobject_cast<PipXtremeGadgetConfiguration*>(config));
|
||||
}
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file pipxtremegadgetfactory.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @{
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "pipxtremegadgetfactory.h"
|
||||
#include "pipxtremegadgetwidget.h"
|
||||
#include "pipxtremegadget.h"
|
||||
#include "pipxtremegadgetconfiguration.h"
|
||||
#include "pipxtremegadgetoptionspage.h"
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
PipXtremeGadgetFactory::PipXtremeGadgetFactory(QObject *parent) :
|
||||
IUAVGadgetFactory(QString("PipXtreme"), tr("PipXtreme Gadget"), parent)
|
||||
{
|
||||
}
|
||||
|
||||
PipXtremeGadgetFactory::~PipXtremeGadgetFactory()
|
||||
{
|
||||
}
|
||||
|
||||
Core::IUAVGadget* PipXtremeGadgetFactory::createGadget(QWidget *parent)
|
||||
{
|
||||
PipXtremeGadgetWidget *gadgetWidget = new PipXtremeGadgetWidget(parent);
|
||||
return new PipXtremeGadget(QString("PipXtreme"), gadgetWidget, parent);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration * PipXtremeGadgetFactory::createConfiguration(QSettings *qSettings)
|
||||
{
|
||||
return new PipXtremeGadgetConfiguration(QString("PipXtreme"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage * PipXtremeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new PipXtremeGadgetOptionsPage(qobject_cast<PipXtremeGadgetConfiguration *>(config));
|
||||
}
|
||||
|
||||
|
@ -1,50 +1,51 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file pipxtremegadgetfactory.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @{
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 PIPXTREMEGADGETFACTORY_H
|
||||
#define PIPXTREMEGADGETFACTORY_H
|
||||
|
||||
#include <coreplugin/iuavgadgetfactory.h>
|
||||
|
||||
namespace Core {
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetFactory;
|
||||
}
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class PipXtremeGadgetFactory : public Core::IUAVGadgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PipXtremeGadgetFactory(QObject *parent = 0);
|
||||
~PipXtremeGadgetFactory();
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
#endif
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file pipxtremegadgetfactory.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @{
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 PIPXTREMEGADGETFACTORY_H
|
||||
#define PIPXTREMEGADGETFACTORY_H
|
||||
|
||||
#include <coreplugin/iuavgadgetfactory.h>
|
||||
|
||||
namespace Core {
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetFactory;
|
||||
}
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class PipXtremeGadgetFactory : public Core::IUAVGadgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PipXtremeGadgetFactory(QObject *parent = 0);
|
||||
~PipXtremeGadgetFactory();
|
||||
|
||||
Core::IUAVGadget * createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration * createConfiguration(QSettings *qSettings);
|
||||
IOptionsPage * createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -24,102 +24,97 @@
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtOpenGL/QGLWidget>
|
||||
|
||||
#include "pipxtremegadgetwidget.h"
|
||||
|
||||
//#include <aggregation/aggregate.h>
|
||||
|
||||
#define SERIAL_PORT 1
|
||||
#define USB_PORT 2
|
||||
|
||||
// ***************************************************************************************
|
||||
|
||||
// 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_config->setupUi(this);
|
||||
m_widget = new Ui_PipXtremeWidget();
|
||||
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;
|
||||
rescueStep = RESCUE_STEP0;
|
||||
resetOnly = false;
|
||||
m_widget->comboBox_Mode->clear();
|
||||
m_widget->comboBox_Mode->addItem("Normal", 0);
|
||||
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_config->comboBox_Mode->addItem("Normal", 0);
|
||||
m_config->comboBox_Mode->addItem("Scan Spectrum", 1);
|
||||
m_config->comboBox_Mode->addItem("Tx Carrier Calibrate", 2);
|
||||
m_config->comboBox_Mode->addItem("Tx Spectrum Test", 3);
|
||||
m_widget->comboBox_SerialPortSpeed->clear();
|
||||
for (int i = 0; i < m_widget->comboBox_SerialBaudrate->count(); i++)
|
||||
m_widget->comboBox_SerialPortSpeed->addItem(m_widget->comboBox_SerialBaudrate->itemText(i), m_widget->comboBox_SerialBaudrate->itemData(i));
|
||||
m_widget->comboBox_SerialPortSpeed->setCurrentIndex(m_widget->comboBox_SerialPortSpeed->findText("57600"));
|
||||
|
||||
m_config->comboBox_SerialBaudrate->clear();
|
||||
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_widget->doubleSpinBox_Frequency->setSingleStep(0.00015625);
|
||||
|
||||
m_config->comboBox_SerialPortSpeed->clear();
|
||||
m_config->comboBox_SerialPortSpeed->addItem("1200", 1200);
|
||||
m_config->comboBox_SerialPortSpeed->addItem("2400", 2400);
|
||||
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_widget->progressBar_RSSI->setMinimum(-120);
|
||||
m_widget->progressBar_RSSI->setMaximum(-20);
|
||||
m_widget->progressBar_RSSI->setValue(-80);
|
||||
|
||||
m_config->doubleSpinBox_Frequency->setSingleStep(0.00015625);
|
||||
|
||||
m_config->graphicsView_Spectrum->setScene(new QGraphicsScene(this));
|
||||
QGraphicsScene *spec_scene = m_config->graphicsView_Spectrum->scene();
|
||||
m_widget->graphicsView_Spectrum->setScene(new QGraphicsScene(this));
|
||||
m_widget->graphicsView_Spectrum->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
// m_widget->graphicsView_Spectrum->setViewport(new QWidget);
|
||||
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)
|
||||
{
|
||||
spec_scene->setBackgroundBrush(Qt::black);
|
||||
spec_scene->setBackgroundBrush(QColor(80, 80, 80));
|
||||
spec_scene->clear();
|
||||
|
||||
// spec_scene->addItem(m_background);
|
||||
// spec_scene->addItem(m_joystickEnd);
|
||||
// spec_scene->setSceneRect(m_background->boundingRect());
|
||||
}
|
||||
|
||||
m_config->pushButton_ScanSpectrum->setEnabled(false);
|
||||
m_widget->pushButton_ScanSpectrum->setEnabled(false);
|
||||
|
||||
// Listen to autopilot connection events
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
|
||||
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()));
|
||||
QIcon rbi;
|
||||
rbi.addFile(QString(":pipxtreme/images/view-refresh.svg"));
|
||||
m_widget->refreshPorts->setIcon(rbi);
|
||||
|
||||
// Note: remove listening to the connection manager, it overlaps with
|
||||
// listening to the telemetry manager, we should only listen to one, not both.
|
||||
// Listen to telemetry connection events
|
||||
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:
|
||||
// Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||
// connect(cm, SIGNAL(deviceDisconnected()), this, SLOT(onModemDisconnect()));
|
||||
getPorts();
|
||||
|
||||
// int opened = rawHidHandle.open(10, 0x20A0, 0x4117, 0xFF9C, 0x0001);
|
||||
// rawHidPlugin = new RawHIDPlugin();
|
||||
|
||||
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()));
|
||||
connect(m_widget->connectButton, SIGNAL(clicked()), this, SLOT(connectDisconnect()));
|
||||
connect(m_widget->refreshPorts, SIGNAL(clicked()), this, SLOT(getPorts()));
|
||||
|
||||
// delay::msleep(600); // just for pips reference
|
||||
}
|
||||
@ -127,16 +122,18 @@ PipXtremeGadgetWidget::PipXtremeGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
// destructor .. this never gets called :(
|
||||
PipXtremeGadgetWidget::~PipXtremeGadgetWidget()
|
||||
{
|
||||
disconnect(false);
|
||||
disconnectPort(false);
|
||||
}
|
||||
|
||||
// ***************************************************************************************
|
||||
|
||||
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)
|
||||
{
|
||||
// spec_scene->setSceneRect(QRect(QPoint(0, 0), event->size()));
|
||||
@ -148,36 +145,66 @@ void PipXtremeGadgetWidget::resizeEvent(QResizeEvent *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)
|
||||
{
|
||||
return (s1.portName < s2.portName);
|
||||
}
|
||||
|
||||
// ***************************************************************************************
|
||||
|
||||
void PipXtremeGadgetWidget::getPorts()
|
||||
{
|
||||
QStringList list;
|
||||
|
||||
// m_config->refreshPorts->setEnabled(false);
|
||||
// m_config->comboBox_Ports->setEnabled(false);
|
||||
disconnect(m_widget->comboBox_Ports, 0, 0, 0);
|
||||
|
||||
m_config->comboBox_Ports->clear();
|
||||
m_widget->comboBox_Ports->clear();
|
||||
|
||||
// ********************************
|
||||
// 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);
|
||||
|
||||
for (int i = 0; i < list.count(); i++)
|
||||
m_config->comboBox_Ports->addItem(list.at(i), 0);
|
||||
|
||||
// m_config->comboBox_Ports->addItems(list);
|
||||
m_widget->comboBox_Ports->addItem(list.at(i), SERIAL_PORT);
|
||||
|
||||
// ********************************
|
||||
// Populate the telemetry combo box with usb ports
|
||||
@ -193,10 +220,10 @@ void PipXtremeGadgetWidget::getPorts()
|
||||
for (int i = 0; i < opened; i++)
|
||||
usb_ports.append(rawHidHandle->getserial(i));
|
||||
|
||||
for (int i = 0; i < usb_ports.count(); i++)
|
||||
m_config->comboBox_Ports->addItem(usb_ports.at(i), 1);
|
||||
qSort(usb_ports.begin(), usb_ports.end());
|
||||
|
||||
// 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;
|
||||
@ -204,43 +231,36 @@ void PipXtremeGadgetWidget::getPorts()
|
||||
|
||||
// ********************************
|
||||
|
||||
// m_config->refreshPorts->setEnabled(true);
|
||||
// m_config->comboBox_Ports->setEnabled(true);
|
||||
connect(m_widget->comboBox_Ports, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxPorts_currentIndexChanged(int)));
|
||||
|
||||
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()
|
||||
{
|
||||
m_config->connectButton->setEnabled(false);
|
||||
m_config->comboBox_Ports->setEnabled(false);
|
||||
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()
|
||||
{
|
||||
m_config->connectButton->setEnabled(true);
|
||||
m_config->comboBox_Ports->setEnabled(true);
|
||||
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()
|
||||
{
|
||||
@ -250,44 +270,28 @@ void PipXtremeGadgetWidget::onTelemetryDisconnect()
|
||||
{
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// ***************************************************************************************
|
||||
|
||||
void PipXtremeGadgetWidget::onModemConnect()
|
||||
{
|
||||
m_config->connectButton->setText(tr(" Disconnect "));
|
||||
m_config->comboBox_Ports->setEnabled(false);
|
||||
m_config->pushButton_ScanSpectrum->setEnabled(true);
|
||||
}
|
||||
void PipXtremeGadgetWidget::disableTelemetry()
|
||||
{ // Suspend telemetry & polling
|
||||
|
||||
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();
|
||||
if (!cm) return;
|
||||
|
||||
// Suspend telemety & polling
|
||||
cm->disconnectDevice();
|
||||
cm->suspendPolling();
|
||||
}
|
||||
|
||||
void PipXtremeGadgetWidget::restartTelemetryPolling()
|
||||
{
|
||||
void PipXtremeGadgetWidget::enableTelemetry()
|
||||
{ // Restart the polling thread
|
||||
|
||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||
if (!cm) return;
|
||||
|
||||
// Restart the polling thread
|
||||
cm->resumePolling();
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
// ***************************************************************************************
|
||||
|
||||
void PipXtremeGadgetWidget::processOutputStream()
|
||||
{
|
||||
@ -297,26 +301,45 @@ void PipXtremeGadgetWidget::processOutputStream()
|
||||
if (!m_ioDevice->isOpen())
|
||||
return;
|
||||
|
||||
// if (m_ioDevice->bytesToWrite() < TX_BUFFER_SIZE )
|
||||
{
|
||||
// m_ioDevice->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH);
|
||||
}
|
||||
// if (m_ioDevice->bytesToWrite() < TX_BUFFER_SIZE )
|
||||
{
|
||||
// m_ioDevice->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
void PipXtremeGadgetWidget::processInputStream()
|
||||
{
|
||||
while (m_ioDevice && m_ioDevice->bytesAvailable() > 0)
|
||||
while (m_ioDevice)
|
||||
{
|
||||
quint8 tmp;
|
||||
m_ioDevice->read((char*)&tmp, 1);
|
||||
quint8 buf;
|
||||
|
||||
// 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
|
||||
|
||||
if (!m_ioDevice)
|
||||
@ -324,56 +347,54 @@ void PipXtremeGadgetWidget::disconnect(bool resume_polling)
|
||||
|
||||
m_ioDevice->close();
|
||||
|
||||
disconnect(m_ioDevice, 0, 0, 0);
|
||||
|
||||
delete m_ioDevice;
|
||||
m_ioDevice = NULL;
|
||||
|
||||
m_config->connectButton->setText("Connect");
|
||||
m_config->comboBox_SerialBaudrate->setEnabled(true);
|
||||
m_config->comboBox_Ports->setEnabled(true);
|
||||
m_config->refreshPorts->setEnabled(true);
|
||||
m_widget->connectButton->setText("Connect");
|
||||
m_widget->comboBox_SerialBaudrate->setEnabled(true);
|
||||
m_widget->comboBox_Ports->setEnabled(true);
|
||||
m_widget->refreshPorts->setEnabled(true);
|
||||
m_widget->pushButton_ScanSpectrum->setEnabled(false);
|
||||
|
||||
restartTelemetryPolling();
|
||||
if (enable_telemetry)
|
||||
enableTelemetry();
|
||||
}
|
||||
|
||||
void PipXtremeGadgetWidget::connectDisconnect()
|
||||
{
|
||||
if (m_ioDevice)
|
||||
{ // disconnect
|
||||
disconnect(true);
|
||||
return;
|
||||
}
|
||||
void PipXtremeGadgetWidget::connectPort()
|
||||
{ // connect the comms port
|
||||
|
||||
// ****************
|
||||
// connect
|
||||
disconnectPort(true);
|
||||
|
||||
int device_idx = m_config->comboBox_Ports->currentIndex();
|
||||
int device_idx = m_widget->comboBox_Ports->currentIndex();
|
||||
if (device_idx < 0)
|
||||
return;
|
||||
|
||||
QString device_str = m_config->comboBox_Ports->currentText().trimmed();
|
||||
QString device_str = m_widget->comboBox_Ports->currentText().trimmed();
|
||||
if (device_str.isEmpty())
|
||||
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;
|
||||
|
||||
// Suspend telemety & polling in case it is not done yet
|
||||
suspendTelemetry();
|
||||
disableTelemetry();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0: // serial port
|
||||
case SERIAL_PORT: // serial port
|
||||
{
|
||||
QString str = getPortDevice(device_str);
|
||||
QString str = getSerialPortDevice(device_str);
|
||||
if (str.isEmpty())
|
||||
break;
|
||||
|
||||
int br_idx = m_config->comboBox_SerialBaudrate->currentIndex();
|
||||
int br_idx = m_widget->comboBox_SerialBaudrate->currentIndex();
|
||||
if (br_idx < 0)
|
||||
break;
|
||||
|
||||
int baudrate = m_config->comboBox_SerialBaudrate->itemData(br_idx).toInt();
|
||||
int baudrate = m_widget->comboBox_SerialBaudrate->itemData(br_idx).toInt();
|
||||
|
||||
BaudRateType bdt = BAUD57600;
|
||||
switch (baudrate)
|
||||
@ -398,7 +419,8 @@ void PipXtremeGadgetWidget::connectDisconnect()
|
||||
settings.FlowControl = FLOW_OFF;
|
||||
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)
|
||||
break;
|
||||
|
||||
@ -409,15 +431,10 @@ void PipXtremeGadgetWidget::connectDisconnect()
|
||||
}
|
||||
|
||||
m_ioDevice = serial_dev;
|
||||
|
||||
m_config->connectButton->setText("Disconnect");
|
||||
m_config->comboBox_SerialBaudrate->setEnabled(false);
|
||||
m_config->comboBox_Ports->setEnabled(false);
|
||||
m_config->refreshPorts->setEnabled(false);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: // USB port
|
||||
case USB_PORT: // USB port
|
||||
{
|
||||
RawHID *usb_dev = new RawHID(device_str);
|
||||
if (!usb_dev)
|
||||
@ -430,104 +447,37 @@ void PipXtremeGadgetWidget::connectDisconnect()
|
||||
}
|
||||
|
||||
m_ioDevice = usb_dev;
|
||||
|
||||
m_config->connectButton->setText("Disconnect");
|
||||
m_config->comboBox_SerialBaudrate->setEnabled(false);
|
||||
m_config->comboBox_Ports->setEnabled(false);
|
||||
m_config->refreshPorts->setEnabled(false);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
default: // unknown
|
||||
default: // unknown port type
|
||||
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::goToAPIMode(UAVObject* callerObj, bool success)
|
||||
void PipXtremeGadgetWidget::connectDisconnect()
|
||||
{
|
||||
Q_UNUSED(callerObj);
|
||||
/*
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
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;
|
||||
*/
|
||||
if (m_ioDevice)
|
||||
disconnectPort(true); // disconnect
|
||||
else
|
||||
connectPort(); // connect
|
||||
}
|
||||
|
||||
// ***************************************************************************************
|
||||
@ -535,9 +485,10 @@ void PipXtremeGadgetWidget::systemBoot()
|
||||
// Shows a message box with an error string.
|
||||
void PipXtremeGadgetWidget::error(QString errorString, int errorNumber)
|
||||
{
|
||||
Q_UNUSED(errorNumber);
|
||||
QMessageBox msgBox;
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setText(errorString + " [" + QString::number(errorNumber) + "]");
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
// ***************************************************************************************
|
||||
|
@ -116,49 +116,42 @@ public:
|
||||
~PipXtremeGadgetWidget();
|
||||
|
||||
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:
|
||||
void onTelemetryStart();
|
||||
void onTelemetryStop();
|
||||
|
||||
void onTelemetryConnect();
|
||||
void onTelemetryDisconnect();
|
||||
|
||||
void onModemConnect();
|
||||
void onModemDisconnect();
|
||||
void onComboBoxPorts_currentIndexChanged(int index);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private:
|
||||
Ui_PipXtremeWidget *m_config;
|
||||
Ui_PipXtremeWidget *m_widget;
|
||||
|
||||
IAPStep currentStep;
|
||||
RescueStep rescueStep;
|
||||
bool resetOnly;
|
||||
QIODevice *m_ioDevice;
|
||||
|
||||
pjrc_rawhid rawHidHandle;
|
||||
// RawHIDPlugin *rawHidPlugin;
|
||||
QString getSerialPortDevice(const QString &friendName);
|
||||
|
||||
// currently connected QIODevice
|
||||
QIODevice *m_ioDevice;
|
||||
|
||||
QString getPortDevice(const QString &friendName);
|
||||
|
||||
void suspendTelemetry();
|
||||
void restartTelemetryPolling();
|
||||
void disableTelemetry();
|
||||
void enableTelemetry();
|
||||
|
||||
void processOutputStream();
|
||||
void processInputStream();
|
||||
|
||||
void disconnect(bool resume_polling);
|
||||
void disconnectPort(bool enable_telemetry);
|
||||
void connectPort();
|
||||
|
||||
void processInputBytes(quint8 *buf, int count);
|
||||
|
||||
private slots:
|
||||
void connectDisconnect();
|
||||
void error(QString errorString,int errorNumber);
|
||||
void goToAPIMode(UAVObject* = NULL, bool = false);
|
||||
void systemBoot();
|
||||
void error(QString errorString, int errorNumber);
|
||||
void getPorts();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,61 +1,59 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file pipxtremeplugin.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @{
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "pipxtremeplugin.h"
|
||||
#include "pipxtremegadgetfactory.h"
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
PipXtremePlugin::PipXtremePlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
PipXtremePlugin::~PipXtremePlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
bool PipXtremePlugin::initialize(const QStringList& args, QString *errMsg)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
Q_UNUSED(errMsg);
|
||||
mf = new PipXtremeGadgetFactory(this);
|
||||
addAutoReleasedObject(mf);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PipXtremePlugin::extensionsInitialized()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void PipXtremePlugin::shutdown()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
Q_EXPORT_PLUGIN(PipXtremePlugin)
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file pipxtremeplugin.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @{
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "pipxtremeplugin.h"
|
||||
#include "pipxtremegadgetfactory.h"
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
PipXtremePlugin::PipXtremePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
PipXtremePlugin::~PipXtremePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
bool PipXtremePlugin::initialize(const QStringList& args, QString *errMsg)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
Q_UNUSED(errMsg);
|
||||
mf = new PipXtremeGadgetFactory(this);
|
||||
addAutoReleasedObject(mf);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PipXtremePlugin::extensionsInitialized()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void PipXtremePlugin::shutdown()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
Q_EXPORT_PLUGIN(PipXtremePlugin)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user