diff --git a/ground/src/experimental/PipXtreme_Config/PipXtreme_Config.pro b/ground/src/experimental/PipXtreme_Config/PipXtreme_Config.pro index 10a66ce54..035906af6 100644 --- a/ground/src/experimental/PipXtreme_Config/PipXtreme_Config.pro +++ b/ground/src/experimental/PipXtreme_Config/PipXtreme_Config.pro @@ -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 diff --git a/ground/src/experimental/PipXtreme_Config/main.cpp b/ground/src/experimental/PipXtreme_Config/main.cpp index a001eb2db..1280d8919 100644 --- a/ground/src/experimental/PipXtreme_Config/main.cpp +++ b/ground/src/experimental/PipXtreme_Config/main.cpp @@ -1,5 +1,6 @@ #include #include "mainwindow.h" +#include int main(int argc, char *argv[]) { diff --git a/ground/src/experimental/PipXtreme_Config/mainwindow.cpp b/ground/src/experimental/PipXtreme_Config/mainwindow.cpp index 12d07c019..321114848 100644 --- a/ground/src/experimental/PipXtreme_Config/mainwindow.cpp +++ b/ground/src/experimental/PipXtreme_Config/mainwindow.cpp @@ -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()); +} diff --git a/ground/src/experimental/PipXtreme_Config/mainwindow.h b/ground/src/experimental/PipXtreme_Config/mainwindow.h index 99cd8b23d..36dca79b8 100644 --- a/ground/src/experimental/PipXtreme_Config/mainwindow.h +++ b/ground/src/experimental/PipXtreme_Config/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include +#include 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 diff --git a/ground/src/experimental/PipXtreme_Config/mainwindow.ui b/ground/src/experimental/PipXtreme_Config/mainwindow.ui index 470812815..70ffa17b5 100644 --- a/ground/src/experimental/PipXtreme_Config/mainwindow.ui +++ b/ground/src/experimental/PipXtreme_Config/mainwindow.ui @@ -20,7 +20,7 @@ - Port + Serial Port Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -37,7 +37,37 @@ - 200 + 150 + 0 + + + + + + + + + + + + Baudrate + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 150 0 @@ -81,6 +111,12 @@ false + + 8 + + + Qt::AlignCenter + true @@ -121,6 +157,12 @@ 0 + + 8 + + + Qt::AlignCenter + @@ -151,6 +193,12 @@ 0 + + 9 + + + Qt::AlignCenter + @@ -181,6 +229,12 @@ 0 + + 9 + + + Qt::AlignCenter + @@ -211,6 +265,12 @@ 0 + + 9 + + + Qt::AlignCenter + @@ -318,7 +378,11 @@ - + + + 256 + +