1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Updating PipX configurator to use the qextserialport .. doesn't compile though :(

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2489 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
pip 2011-01-20 13:24:31 +00:00 committed by pip
parent 2bb935b223
commit 24a77b47a2
5 changed files with 170 additions and 5 deletions

View File

@ -9,10 +9,30 @@ QT += core gui
TARGET = PipXtreme_Config
TEMPLATE = app
INCLUDEPATH += ../../libs/qextserialport/src
SOURCES += main.cpp\
mainwindow.cpp
mainwindow.cpp \
HEADERS += mainwindow.h
HEADERS += mainwindow.h \
HEADERS += ../../libs/qextserialport/src/qextserialport.h \
../../libs/qextserialport/src/qextserialenumerator.h \
../../libs/qextserialport/src/qextserialport_global.h
SOURCES = ../../libs/qextserialport/src/qextserialport.cpp
unix:SOURCES += ../../libs/qextserialport/src/posix_qextserialport.cpp
unix:!macx:SOURCES += ../../libs/qextserialport/src/qextserialenumerator_unix.cpp
macx {
SOURCES += ../../libs/qextserialport/src/qextserialenumerator_osx.cpp
LIBS += -framework IOKit -framework CoreFoundation
}
win32 {
SOURCES += ../../libs/qextserialport/src/win_qextserialport.cpp \
../../libs/qextserialport/src/qextserialenumerator_win.cpp
DEFINES += WINVER=0x0501 # needed for mingw to pull in appropriate dbt business...probably a better way to do this
LIBS += -lsetupapi
}
FORMS += mainwindow.ui

View File

@ -1,5 +1,6 @@
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <qextserialport.h>
int main(int argc, char *argv[])
{

View File

@ -1,3 +1,4 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
@ -6,9 +7,80 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow)
{
ui->setupUi(this);
port = NULL;
port = new QextSerialPort(QextSerialPort::EventDriven);
if (port)
{
port->setPortName("COM1");
port->setBaudRate(BAUD57600);
port->setFlowControl(FLOW_OFF);
port->setParity(PAR_NONE);
port->setDataBits(DATA_8);
port->setStopBits(STOP_1);
connect(port, SIGNAL(readyRead()), this, SLOT(onDataAvailable()));
port->open(0);
qDebug("isOpen : %d", port->isOpen());
}
}
MainWindow::~MainWindow()
{
if (port)
{
if (port->isOpen())
port->close();
delete port;
port = NULL;
}
delete ui;
}
void MainWindow::onDataAvailable()
{
if (!port)
return;
int avail = port->bytesAvailable();
if (avail <= 0)
return;
QByteArray data;
data.resize(avail);
int read = port->read(data.data(), data.size());
if (read <= 0)
return;
qDebug("bytes available: %d", avail);
qDebug("received: %d", read);
}
void MainWindow::closePort()
{
if (!port)
return;
port->close();
qDebug("is open: %d", port->isOpen());
}
void MainWindow::openPort()
{
if (!port)
return;
port->open(QIODevice::ReadWrite);
qDebug("is open: %d", port->isOpen());
}

View File

@ -2,6 +2,7 @@
#define MAINWINDOW_H
#include <QMainWindow>
#include <qextserialport.h>
namespace Ui {
class MainWindow;
@ -17,6 +18,13 @@ public:
private:
Ui::MainWindow *ui;
QextSerialPort *port;
private slots:
void onDataAvailable();
void closePort();
void openPort();
};
#endif // MAINWINDOW_H

View File

@ -20,7 +20,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Port</string>
<string> Serial Port </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -37,7 +37,37 @@
</property>
<property name="minimumSize">
<size>
<width>200</width>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string> Baudrate </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
@ -81,6 +111,12 @@
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="maxLength">
<number>8</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
@ -121,6 +157,12 @@
<height>0</height>
</size>
</property>
<property name="maxLength">
<number>8</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
@ -151,6 +193,12 @@
<height>0</height>
</size>
</property>
<property name="maxLength">
<number>9</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
@ -181,6 +229,12 @@
<height>0</height>
</size>
</property>
<property name="maxLength">
<number>9</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
@ -211,6 +265,12 @@
<height>0</height>
</size>
</property>
<property name="maxLength">
<number>9</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
@ -318,7 +378,11 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
<widget class="QLineEdit" name="lineEdit">
<property name="maxLength">
<number>256</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_AESEncryption">