1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Test version of Ymodem Plugin

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@464 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-04-10 00:09:53 +00:00 committed by zedamota
parent e868af8efe
commit ac88f788be
14 changed files with 1167 additions and 0 deletions

View File

@ -0,0 +1,10 @@
<plugin name="Uploader" version="0.0.1" compatVersion="1.0.0">
<vendor>Jose Barros A.K.A. PT_Dreamer</vendor>
<copyright>(C) 2010 OpenPilot Project</copyright>
<license>The GNU Public License (GPL) Version 3</license>
<description>A plugin to Upload Firmware to the OpenPilot HW via Ymodem protocol</description>
<url>http://www.openpilot.org</url>
<dependencyList>
<dependency name="Core" version="1.0.0"/>
</dependencyList>
</plugin>

View File

@ -0,0 +1,25 @@
TEMPLATE = lib
TARGET = Uploader
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
HEADERS += uploadergadget.h \
uploadergadgetconfiguration.h \
uploadergadgetfactory.h \
uploadergadgetoptionspage.h \
uploadergadgetwidget.h \
uploaderplugin.h
SOURCES += uploaderGadget.cpp \
uploadergadgetconfiguration.cpp \
uploadergadgetfactory.cpp \
uploadergadgetoptionspage.cpp \
uploadergadgetwidget.cpp \
uploaderplugin.cpp
OTHER_FILES += uploader.pluginspec
LIBS += -l$$qtLibraryTarget(QExtSerialPort)
LIBS += -l$$qtLibraryTarget(QYmodem)
#CONFIG(debug, debug|release):LIBS += -lqextserialportd
#else:LIBS += -lqextserialport
#CONFIG(debug, debug|release):LIBS += -lqymodemd
#else:LIBS += -lqymodem

View File

@ -0,0 +1,60 @@
/**
******************************************************************************
*
* @file UploaderGadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 "uploadergadget.h"
#include "uploadergadgetwidget.h"
#include "uploadergadgetconfiguration.h"
//#include "./qextserialport/qextserialbase.h"
//#include "./qextserialport/qextserialenumerator.h"
//#include "./qextserialport/qextserialPort.h"
#include <qextserialport/src/qextserialport.h>
#include <qextserialport/src/qextserialenumerator.h>
UploaderGadget::UploaderGadget(QString classId, UploaderGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
UploaderGadget::~UploaderGadget()
{
}
void UploaderGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
UploaderGadgetConfiguration *m = qobject_cast< UploaderGadgetConfiguration*>(config);
PortSettings portsettings;
portsettings.BaudRate=m->Speed();
portsettings.DataBits=m->DataBits();
portsettings.FlowControl=m->Flow();
portsettings.Parity=m->Parity();
portsettings.StopBits=m->StopBits();
portsettings.Timeout_Millisec=m->TimeOut();
QextSerialPort *port=new QextSerialPort(m->Port(),portsettings,QextSerialPort::Polling);
m_widget->setPort(port);
}

View File

@ -0,0 +1,57 @@
/**
******************************************************************************
*
* @file Uploadergadget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 UPLOADERGADGET_H
#define UPLOADERGADGET_H
#include <coreplugin/iuavgadget.h>
#include "uploadergadgetwidget.h"
class IUAVGadget;
//class QList<int>;
class QWidget;
class QString;
class UploaderGadgetWidget;
using namespace Core;
class UploaderGadget : public Core::IUAVGadget
{
Q_OBJECT
public:
UploaderGadget(QString classId, UploaderGadgetWidget *widget, QWidget *parent = 0);
~UploaderGadget();
QWidget *widget() { return m_widget; }
void loadConfiguration(IUAVGadgetConfiguration* config);
private:
UploaderGadgetWidget *m_widget;
};
#endif // UPLOADERGADGET_H

View File

@ -0,0 +1,106 @@
/**
******************************************************************************
*
* @file UploaderGadgetconfiguration.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 "uploadergadgetconfiguration.h"
#include <QtCore/QDataStream>
#include <qextserialport/src/qextserialport.h>
UploaderGadgetConfiguration::UploaderGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_defaultPort("Unknown"),
m_defaultSpeed(BAUD19200),
m_defaultDataBits(DATA_8),
m_defaultFlow(FLOW_OFF),
m_defaultParity(PAR_NONE),
m_defaultStopBits(STOP_1),
m_defaultTimeOut(5000)
{
if (state.count() > 0) {
QDataStream stream(state);
BaudRateType speed;
DataBitsType databits;
FlowType flow;
ParityType parity;
StopBitsType stopbits;
int ispeed;
int idatabits;
int iflow;
int iparity;
int istopbits;
QString port;
stream >> ispeed;
stream >> idatabits;
stream >>iflow;
stream >>iparity;
stream >> istopbits;
stream >> port;
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;
}
}
IUAVGadgetConfiguration *UploaderGadgetConfiguration::clone()
{
UploaderGadgetConfiguration *m = new UploaderGadgetConfiguration(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;
}
QByteArray UploaderGadgetConfiguration::saveState() const
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << (int)m_defaultSpeed;
stream << (int)m_defaultDataBits;
stream << (int)m_defaultFlow;
stream << (int)m_defaultParity;
stream << (int)m_defaultStopBits;
stream << m_defaultPort;
return bytes;
}

View File

@ -0,0 +1,73 @@
/**
******************************************************************************
*
* @file UploaderGadgetconfiguration.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 UPLOADERGADGETCONFIGURATION_H
#define UPLOADERGADGETCONFIGURATION_H
#include <coreplugin/iuavgadgetconfiguration.h>
#include <qextserialport/src/qextserialport.h>
using namespace Core;
class UploaderGadgetConfiguration : public IUAVGadgetConfiguration
{
Q_OBJECT
public:
explicit UploaderGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
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;}
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;}
QByteArray saveState() const;
IUAVGadgetConfiguration *clone();
signals:
public slots:
private:
QString m_defaultPort;
BaudRateType m_defaultSpeed;
DataBitsType m_defaultDataBits;
FlowType m_defaultFlow;
ParityType m_defaultParity;
StopBitsType m_defaultStopBits;
long m_defaultTimeOut;
};
#endif // UPLOADERGADGETCONFIGURATION_H

View File

@ -0,0 +1,58 @@
/**
******************************************************************************
*
* @file UploaderGadgetfactory.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 "uploadergadgetfactory.h"
#include "uploadergadgetwidget.h"
#include "uploadergadget.h"
#include "uploadergadgetconfiguration.h"
#include "uploadergadgetoptionspage.h"
#include <coreplugin/iuavgadget.h>
UploaderGadgetFactory::UploaderGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("Uploader"), tr("Uploader Gadget"), parent)
{
}
UploaderGadgetFactory::~UploaderGadgetFactory()
{
}
Core::IUAVGadget* UploaderGadgetFactory::createGadget(QWidget *parent)
{
UploaderGadgetWidget* gadgetWidget = new UploaderGadgetWidget(parent);
return new UploaderGadget(QString("Uploader"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *UploaderGadgetFactory::createConfiguration(const QByteArray &state)
{
return new UploaderGadgetConfiguration(QString("Uploader"), state);
}
IOptionsPage *UploaderGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{
return new UploaderGadgetOptionsPage(qobject_cast<UploaderGadgetConfiguration*>(config));
}

View File

@ -0,0 +1,52 @@
/**
******************************************************************************
*
* @file UploaderGadgetfactory.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 UPLOADERGADGETFACTORY_H
#define UPLOADERGADGETFACTORY_H
#include <coreplugin/iuavgadgetfactory.h>
namespace Core {
class IUAVGadget;
class IUAVGadgetFactory;
}
using namespace Core;
class UploaderGadgetFactory : public Core::IUAVGadgetFactory
{
Q_OBJECT
public:
UploaderGadgetFactory(QObject *parent = 0);
~UploaderGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};
#endif // UPLOADERGADGETFACTORY_H

View File

@ -0,0 +1,321 @@
/**
******************************************************************************
*
* @file UploaderGadgetoptionspage.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 "uploadergadgetoptionspage.h"
#include "uploadergadgetconfiguration.h"
#include <QtGui/QLabel>
#include <QtGui/QSpinBox>
#include <QtGui/QDoubleSpinBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QVBoxLayout>
#include <QtGui/QTextEdit>
#include <QtGui/QComboBox>
#include <QtAlgorithms>
#include <QStringList>
#include <qextserialport/src/qextserialenumerator.h>
UploaderGadgetOptionsPage::UploaderGadgetOptionsPage(UploaderGadgetConfiguration *config, QObject *parent) :
IOptionsPage(parent),
m_config(config)
{
#ifdef _TTY_POSIX_
BaudRateTypeString
<<"BAUD50" //POSIX ONLY
<<"BAUD75" //POSIX ONLY
<<"BAUD110"
<<"BAUD134" //POSIX ONLY
<<"BAUD150" //POSIX ONLY
<<"BAUD200" //POSIX ONLY
<<"BAUD300"
<<"BAUD600"
<<"BAUD1200"
<<"BAUD1800" //POSIX ONLY
<<"BAUD2400"
<<"BAUD4800"
<<"BAUD9600"
<<"BAUD19200"
<<"BAUD38400"
<<"BAUD57600"
<<"BAUD76800" //POSIX ONLY
<<"BAUD115200";
DataBitsTypeString
<<"DATA_5"
<<"DATA_6"
<<"DATA_7"
<<"DATA_8";
ParityTypeString
<<"PAR_NONE"
<<"PAR_ODD"
<<"PAR_EVEN"
<<"PAR_SPACE";
StopBitsTypeString
<<"STOP_1"
<<"STOP_2";
#else
BaudRateTypeString
<<"BAUD110"
<<"BAUD300"
<<"BAUD600"
<<"BAUD1200"
<<"BAUD2400"
<<"BAUD4800"
<<"BAUD9600"
<<"BAUD14400"
<<"BAUD19200"
<<"BAUD38400"
<<"BAUD56000"
<<"BAUD57600"
<<"BAUD115200"
<<"BAUD128000"
<<"BAUD256000";
DataBitsTypeString
<<"DATA_5"
<<"DATA_6"
<<"DATA_7"
<<"DATA_8";
ParityTypeString
<<"PAR_NONE"
<<"PAR_ODD"
<<"PAR_EVEN"
<<"PAR_MARK" //WINDOWS ONLY
<<"PAR_SPACE";
StopBitsTypeString
<<"STOP_1"
<<"STOP_1_5" //WINDOWS ONLY
<<"STOP_2";
#endif
BaudRateTypeStringALL
<<"BAUD50" //POSIX ONLY
<<"BAUD75" //POSIX ONLY
<<"BAUD110"
<<"BAUD134" //POSIX ONLY
<<"BAUD150" //POSIX ONLY
<<"BAUD200" //POSIX ONLY
<<"BAUD300"
<<"BAUD600"
<<"BAUD1200"
<<"BAUD1800" //POSIX ONLY
<<"BAUD2400"
<<"BAUD4800"
<<"BAUD9600"
<<"BAUD14400"
<<"BAUD19200"
<<"BAUD38400"
<<"BAUD56000"
<<"BAUD57600"
<<"BAUD76800" //POSIX ONLY
<<"BAUD115200"
<<"BAUD128000"
<<"BAUD256000";
DataBitsTypeStringALL
<<"DATA_5"
<<"DATA_6"
<<"DATA_7"
<<"DATA_8";
ParityTypeStringALL
<<"PAR_NONE"
<<"PAR_ODD"
<<"PAR_EVEN"
<<"PAR_MARK" //WINDOWS ONLY
<<"PAR_SPACE";
StopBitsTypeStringALL
<<"STOP_1"
<<"STOP_1_5" //WINDOWS ONLY
<<"STOP_2";
FlowTypeString
<<"FLOW_OFF"
<<"FLOW_HARDWARE"
<<"FLOW_XONXOFF";
}
QWidget *UploaderGadgetOptionsPage::createPage(QWidget *parent)
{
QWidget *widget = new QWidget;
//main layout
QVBoxLayout *vl = new QVBoxLayout();
widget->setLayout(vl);
//port layout
QHBoxLayout *portLayout = new QHBoxLayout();
QWidget *x = new QWidget;
x->setLayout(portLayout);
QWidget *label = new QLabel("Port:");
m_portCB = new QComboBox(parent);
portLayout->addWidget(label);
portLayout->addWidget(m_portCB);
//port speed layout
QHBoxLayout *speedLayout = new QHBoxLayout();
QWidget *y = new QWidget;
y->setLayout(speedLayout);
label = new QLabel("Port Speed:");
m_speedCB = new QComboBox();
speedLayout->addWidget(label);
speedLayout->addWidget(m_speedCB);
//flow control layout
QHBoxLayout *flowLayout = new QHBoxLayout();
QWidget *z = new QWidget;
z->setLayout(flowLayout);
label = new QLabel("Flow Control:");
m_flowCB = new QComboBox();
flowLayout->addWidget(label);
flowLayout->addWidget(m_flowCB);
//databits layout
QHBoxLayout *databitsLayout = new QHBoxLayout();
QWidget *a = new QWidget;
a->setLayout(databitsLayout);
label = new QLabel("Data Bits:");
m_databitsCB = new QComboBox();
databitsLayout->addWidget(label);
databitsLayout->addWidget(m_databitsCB);
//stopbits layout
QHBoxLayout *stopbitsLayout = new QHBoxLayout();
QWidget *b = new QWidget;
b->setLayout(stopbitsLayout);
label = new QLabel("Stop Bits:");
m_stopbitsCB = new QComboBox();
stopbitsLayout->addWidget(label);
stopbitsLayout->addWidget(m_stopbitsCB);
//parity layout
QHBoxLayout *parityLayout = new QHBoxLayout();
QWidget *c = new QWidget;
c->setLayout(parityLayout);
label = new QLabel("Parity:");
m_parityCB = new QComboBox();
parityLayout->addWidget(label);
parityLayout->addWidget(m_parityCB);
//timeout layout
QHBoxLayout *timeoutLayout = new QHBoxLayout();
QWidget *d = new QWidget;
d->setLayout(timeoutLayout);
label = new QLabel("TimeOut(ms):");
m_timeoutSpin = new QSpinBox();
m_timeoutSpin->setMaximum(100000);
timeoutLayout->addWidget(label);
timeoutLayout->addWidget(m_timeoutSpin);
QSpacerItem *spacer = new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding);
vl->addWidget(x);
vl->addWidget(y);
vl->addWidget(z);
vl->addWidget(a);
vl->addWidget(b);
vl->addWidget(c);
vl->addWidget(d);
vl->addSpacerItem(spacer);
m_portCB->clear();
m_speedCB->clear();
m_databitsCB->clear();
m_flowCB->clear();
m_parityCB->clear();
m_stopbitsCB->clear();
QList<QextPortInfo> ports =QextSerialEnumerator ::getPorts();
qSort(ports.begin(), ports.end());
for (int i = 0; i < ports.size(); i++) {
m_portCB->addItem((QString)ports.at(i).portName.toLocal8Bit().constData());
}
if(m_portCB->findText(m_config->Port())!=-1){
m_portCB->setCurrentIndex(m_portCB->findText(m_config->Port()));
}
for (int i=0;i<BaudRateTypeString.size();i++){
m_speedCB->addItem(BaudRateTypeString.at(i).toLocal8Bit().constData() );
}
if(m_speedCB->findText(BaudRateTypeStringALL.at((int)m_config->Speed()).toLocal8Bit().constData())!=-1){
m_speedCB->setCurrentIndex(m_speedCB->findText(BaudRateTypeStringALL.at((int)m_config->Speed()).toLocal8Bit().constData()));
}
for (int i=0;i<DataBitsTypeString.size();i++){
m_databitsCB->addItem(DataBitsTypeString.at(i).toLocal8Bit().constData() );
}
if(m_databitsCB->findText(DataBitsTypeStringALL.at((int)m_config->DataBits()).toLocal8Bit().constData())!=-1){
m_databitsCB->setCurrentIndex(m_databitsCB->findText(DataBitsTypeStringALL.at((int)m_config->DataBits()).toLocal8Bit().constData()));
}
for (int i=0;i<ParityTypeString.size();i++){
m_parityCB->addItem(ParityTypeString.at(i).toLocal8Bit().constData() );
}
if(m_parityCB->findText(ParityTypeStringALL.at((int)m_config->Parity()).toLocal8Bit().constData())!=-1){
m_parityCB->setCurrentIndex(m_parityCB->findText(ParityTypeStringALL.at((int)m_config->Parity()).toLocal8Bit().constData()));
}
for (int i=0;i<StopBitsTypeString.size();i++){
m_stopbitsCB->addItem(StopBitsTypeString.at(i).toLocal8Bit().constData() );
}
if(m_stopbitsCB->findText(StopBitsTypeStringALL.at((int)m_config->StopBits()).toLocal8Bit().constData())!=-1){
m_stopbitsCB->setCurrentIndex(m_stopbitsCB->findText(StopBitsTypeStringALL.at((int)m_config->StopBits()).toLocal8Bit().constData()));
}
for (int i=0;i<FlowTypeString.size();i++){
m_flowCB->addItem(FlowTypeString.at(i).toLocal8Bit().constData() );
}
if(m_flowCB->findText(FlowTypeString.at((int)m_config->Flow()).toLocal8Bit().constData())!=-1){
m_flowCB->setCurrentIndex(m_flowCB->findText(FlowTypeString.at((int)m_config->Flow()).toLocal8Bit().constData()));
}
m_timeoutSpin->setValue(m_config->TimeOut());
return widget;
}
/**
* Called when the user presses apply or OK.
*
* Saves the current values
*
*/
void UploaderGadgetOptionsPage::apply()
{
m_config->setPort(m_portCB->currentText());
m_config->setSpeed((BaudRateType)BaudRateTypeStringALL.indexOf(m_speedCB->currentText()));
m_config->setDataBits((DataBitsType)DataBitsTypeStringALL.indexOf(m_databitsCB->currentText()));
m_config->setStopBits((StopBitsType)StopBitsTypeStringALL.indexOf(m_stopbitsCB->currentText()));
m_config->setParity((ParityType)ParityTypeStringALL.indexOf(m_parityCB->currentText()));
m_config->setFlow((FlowType)FlowTypeString.indexOf(m_flowCB->currentText()));
m_config->setTimeOut( m_timeoutSpin->value());
}
void UploaderGadgetOptionsPage::finish()
{
}

View File

@ -0,0 +1,77 @@
/**
******************************************************************************
*
* @file UploaderGadgetoptionspage.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 UPLOADERGADGETOPTIONSPAGE_H
#define UPLOADERGADGETOPTIONSPAGE_H
#include "coreplugin/dialogs/ioptionspage.h"
#include "QString"
#include <QStringList>
namespace Core {
class IUAVGadgetConfiguration;
}
class UploaderGadgetConfiguration;
class QTextEdit;
class QComboBox;
class QSpinBox;
using namespace Core;
class UploaderGadgetOptionsPage : public IOptionsPage
{
Q_OBJECT
public:
explicit UploaderGadgetOptionsPage(UploaderGadgetConfiguration *config, QObject *parent = 0);
QWidget *createPage(QWidget *parent);
void apply();
void finish();
signals:
public slots:
private:
UploaderGadgetConfiguration *m_config;
QComboBox *m_portCB;
QComboBox *m_speedCB;
QComboBox *m_databitsCB;
QComboBox *m_flowCB;
QComboBox *m_parityCB;
QComboBox *m_stopbitsCB;
QSpinBox *m_timeoutSpin;
QStringList BaudRateTypeString;
QStringList BaudRateTypeStringALL;
QStringList DataBitsTypeStringALL;
QStringList ParityTypeStringALL;
QStringList StopBitsTypeStringALL;
QStringList DataBitsTypeString;
QStringList ParityTypeString;
QStringList StopBitsTypeString;
QStringList FlowTypeString;
};
#endif // UPLOADERGADGETOPTIONSPAGE_H

View File

@ -0,0 +1,137 @@
/**
******************************************************************************
*
* @file UploaderGadgetwidget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 "uploadergadgetwidget.h"
UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
QVBoxLayout *layout = new QVBoxLayout;
QHBoxLayout *FileLayout = new QHBoxLayout;
QWidget *FileWidget = new QWidget;
FileWidget->setLayout(FileLayout);
openFileNameLE=new QLineEdit();
QPushButton* loadfile = new QPushButton("Load File");
loadfile->setMaximumWidth(80);
FileLayout->addWidget(openFileNameLE);
FileLayout->addWidget(loadfile);
QHBoxLayout *SendLayout = new QHBoxLayout;
QWidget *SendWidget = new QWidget;
SendWidget->setLayout(SendLayout);
progressBar=new QProgressBar();
progressBar->setMaximum(100);
QPushButton* sendBt = new QPushButton("Send");
sendBt->setMaximumWidth(80);
SendLayout->addWidget(progressBar);
SendLayout->addWidget(sendBt);
QHBoxLayout *StatusLayout = new QHBoxLayout;
QWidget *StatusWidget = new QWidget;
StatusWidget->setLayout(StatusLayout);
status=new QLabel();
StatusLayout->addWidget(status);
layout->addWidget(FileWidget);
layout->addWidget(SendWidget);
layout->addWidget(StatusWidget);
setLayout(layout);
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()),
this, SLOT(updatePerc()));
connect(loadfile, SIGNAL(clicked(bool)),
this,SLOT(setOpenFileName()));
connect(sendBt, SIGNAL(clicked(bool)),
this,SLOT(send()));
}
void UploaderGadgetWidget::updatePerc()
{
if(Ymodem->isRunning())
{
progressBar->setValue(Ymodem->PercentSend());
}
else
timer->stop();
}
void UploaderGadgetWidget::send()
{
Ymodem->SendFileT(openFileNameLE->text());
timer->start();
}
UploaderGadgetWidget::~UploaderGadgetWidget()
{
delete Port;
delete Ymodem;
}
void UploaderGadgetWidget::setPort(QextSerialPort* port)
{
Port=port;
Ymodem=new QymodemSend(*Port);
connect(Ymodem,SIGNAL(Error(QString,int))
,this,SLOT(error(QString,int)));
connect(Ymodem,SIGNAL(Information(QString,int)),
this,SLOT(info(QString,int)));
}
void UploaderGadgetWidget::setOpenFileName()
{
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getOpenFileName(this,
tr("QFileDialog::getOpenFileName()"),
openFileNameLE->text(),
tr("All Files (*);;Text Files (*.bin)"),
&selectedFilter,
options);
if (!fileName.isEmpty()) openFileNameLE->setText(fileName);
}
void UploaderGadgetWidget::error(QString errorString, int errorNumber)
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(errorString);
msgBox.exec();
status->setText(errorString);
}
void UploaderGadgetWidget::info(QString infoString, int infoNumber)
{
status->setText(infoString);
}

View File

@ -0,0 +1,80 @@
/**
******************************************************************************
*
* @file UploaderGadgetwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 UPLOADERGADGETWIDGET_H
#define UPLOADERGADGETWIDGET_H
//#include "qmapcontrol/qmapcontrol.h"
#include <QtGui/QWidget>
#include <qextserialport/src/qextserialport.h>
#include <qymodem/src/qymodemsend.h>
#include <QLabel>
#include <QLineEdit>
#include <QThread>
# include <QProgressBar>
#include <QStringList>
#include <QtGui/QVBoxLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QPushButton>
#include <QFileDialog>
#include <QMessageBox>
#include <QTimer>
//using namespace qmapcontrol;
class UploaderGadgetWidget : public QWidget
{
Q_OBJECT
public:
UploaderGadgetWidget(QWidget *parent = 0);
~UploaderGadgetWidget();
void setPort(QextSerialPort* port);
protected:
// void resizeEvent(QResizeEvent *event);
private:
QLineEdit* openFileNameLE;
QextSerialPort *Port;
QLabel* status;
QymodemSend * Ymodem;
QProgressBar *progressBar;
QTimer *timer;
private slots:
void setOpenFileName();
void send();
void error(QString errorString,int errorNumber);
void info(QString infoString,int infoNumber);
void updatePerc();
};
#endif // UPLOADERGADGETWIDGET_H

View File

@ -0,0 +1,64 @@
/**
******************************************************************************
*
* @file UploaderPlugin.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 "uploaderplugin.h"
#include "uploadergadgetfactory.h"
#include <QtPlugin>
#include <QStringList>
#include <extensionsystem/pluginmanager.h>
UploaderPlugin::UploaderPlugin()
{
// Do nothing
}
UploaderPlugin::~UploaderPlugin()
{
// Do nothing
}
bool UploaderPlugin::initialize(const QStringList& args, QString *errMsg)
{
Q_UNUSED(args);
Q_UNUSED(errMsg);
mf = new UploaderGadgetFactory(this);
addAutoReleasedObject(mf);
return true;
}
void UploaderPlugin::extensionsInitialized()
{
// Do nothing
}
void UploaderPlugin::shutdown()
{
// Do nothing
}
Q_EXPORT_PLUGIN(UploaderPlugin)

View File

@ -0,0 +1,47 @@
/**
******************************************************************************
*
* @file UploaderPlugin.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup Uploader
* @{
*
*****************************************************************************/
/*
* 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 UPLOADERPLUGIN_H
#define UPLOADERPLUGIN_H
#include <extensionsystem/iplugin.h>
class UploaderGadgetFactory;
class UploaderPlugin : public ExtensionSystem::IPlugin
{
public:
UploaderPlugin();
~UploaderPlugin();
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString * errorString);
void shutdown();
private:
UploaderGadgetFactory *mf;
};
#endif // UPLOADERPLUGIN_H