Skip to content

Commit

Permalink
Revert "QExtSerialPort"
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Jun 16, 2015
1 parent 7e6bb39 commit 271a73e
Show file tree
Hide file tree
Showing 56 changed files with 46 additions and 6,118 deletions.
6 changes: 2 additions & 4 deletions BLDC_Tool.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
qcustomplot.cpp \
# serialport.cpp \
serialport.cpp \
digitalfiltering.cpp \
packetinterface.cpp \
utility.cpp \
Expand All @@ -27,7 +27,7 @@ SOURCES += main.cpp\

HEADERS += mainwindow.h \
qcustomplot.h \
# serialport.h \
serialport.h \
digitalfiltering.h \
packetinterface.h \
utility.h \
Expand All @@ -40,5 +40,3 @@ FORMS += mainwindow.ui \
mrichtextedit.ui

RESOURCES +=

include(qextserialport-1.2rc/src/qextserialport.pri)
66 changes: 31 additions & 35 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <string.h>
#include <cmath>
#include <QMessageBox>
#include <algorithm>
#include "digitalfiltering.h"

namespace {
Expand Down Expand Up @@ -54,6 +53,7 @@ MainWindow::MainWindow(QWidget *parent) :
mFwVersionReceived = false;
mCompatibleFws.append(qMakePair(1, 2));
mCompatibleFws.append(qMakePair(1, 3));
mCompatibleFws.append(qMakePair(1, 4));

QString supportedFWs;
for (int i = 0;i < mCompatibleFws.size();i++) {
Expand All @@ -66,8 +66,8 @@ MainWindow::MainWindow(QWidget *parent) :
}
ui->firmwareSupportedLabel->setText(supportedFWs);

// mPort = new SerialPort(this);
mPort = new QextSerialPort(QextSerialPort::EventDriven,this);
mPort = new SerialPort(this);

mTimer = new QTimer(this);
mTimer->setInterval(20);
mTimer->start();
Expand All @@ -87,7 +87,7 @@ MainWindow::MainWindow(QWidget *parent) :
mAppconfLoaded = false;
mStatusInfoTime = 0;

connect(mPort, SIGNAL(readyRead()),
connect(mPort, SIGNAL(serial_data_available()),
this, SLOT(serialDataAvailable()));
connect(mTimer, SIGNAL(timeout()), this, SLOT(timerSlot()));

Expand Down Expand Up @@ -1091,46 +1091,52 @@ void MainWindow::timerSlot()
void MainWindow::packetDataToSend(QByteArray &data)
{
if (mPort->isOpen()) {
mPort->write(data.data(), data.size());
// mPort->writeData(data.data(), data.size());
mPort->writeData(data.data(), data.size());
}
}

void MainWindow::fwVersionReceived(int major, int minor)
{
QPair<int, int> highest_supported = *std::max_element(mCompatibleFws.begin(), mCompatibleFws.end());
QPair<int, int> fw_connected = qMakePair(major, minor);

if (major < 0) {
mFwVersionReceived = false;
// mPort->closePort();
mPort->close();
mPort->closePort();
QMessageBox messageBox;
messageBox.critical(this, "Error", "The firmware on the connected VESC is too old. Please"
" update it and try again.");
" update it using a programmer.");
ui->firmwareVersionLabel->setText("Old Firmware");
} else if (!mCompatibleFws.contains(qMakePair(major, minor))) {
if (qMakePair(major, minor) >= qMakePair(1, 1)) {
} else if (fw_connected > highest_supported) {
mFwVersionReceived = true;
mPacketInterface->setLimitedMode(true);
QMessageBox messageBox;
messageBox.warning(this, "Warning", "The connected VESC has newer firmware than this version of"
" BLDC Tool supports. It is recommended that you update BLDC "
" Tool to the latest version. Alternatively, the firmware on"
" the connected VESC can be downgraded in the firmware tab."
" Until then, limited communication mode will be used where"
" only the firmware can be changed.");
} else if (!mCompatibleFws.contains(fw_connected)) {
if (fw_connected >= qMakePair(1, 1)) {
mFwVersionReceived = true;
mPacketInterface->setLimitedMode(true);
QMessageBox messageBox;
messageBox.warning(this, "Warning", "This version of BLDC Tool and the firmware on the"
" connected VESC are not compatible. Please update BLDC Tool"
" and/or the VESC firmware. Since the connected VESC has a firmware"
" with bootloader support, it can be updated from the Firmware tab."
messageBox.warning(this, "Warning", "The connected VESC has too old firmware. Since the"
" connected VESC has firmware with bootloader support, it can be"
" updated from the Firmware tab."
" Until then, limited communication mode will be used where only the"
" firmware can be changed.");
} else {
mFwVersionReceived = false;
// mPort->closePort();
mPort->close();
mPort->closePort();
QMessageBox messageBox;
messageBox.critical(this, "Error", "This version of BLDC Tool and the firmware on the"
" connected VESC are not compatible. Please update BLDC Tool"
" and/or the VESC firmware.");
messageBox.critical(this, "Error", "The firmware on the connected VESC is too old. Please"
" update it using a programmer.");
}
} else {
mFwVersionReceived = true;

QPair<int, int> max = *std::max_element(mCompatibleFws.begin(), mCompatibleFws.end());
if (qMakePair(major, minor) < max) {
if (fw_connected < highest_supported) {
QMessageBox messageBox;
messageBox.warning(this, "Warning", "The connected VESC has compatible, but old"
" firmware. It is recommended that you update it.");
Expand Down Expand Up @@ -1621,22 +1627,12 @@ void MainWindow::decodedChukReceived(double chuk_value)

void MainWindow::on_connectButton_clicked()
{
// mPort->openPort(ui->serialDeviceEdit->text());
mPort->setPortName(ui->serialDeviceEdit->text());
mPort->open(QIODevice::ReadWrite);

mPort->setBaudRate(BAUD115200);
mPort->setDataBits(DATA_8); //8 bits
mPort->setParity(PAR_NONE); //no parity
mPort->setStopBits(STOP_1); //1 stop bit
mPort->setFlowControl(FLOW_OFF); //no flow control
mPort->setTimeout(-1); // TODO ? useless ?
mPort->openPort(ui->serialDeviceEdit->text());
}

void MainWindow::on_disconnectButton_clicked()
{
// mPort->closePort();
mPort->close();
mPort->closePort();
}

void MainWindow::on_getDataButton_clicked()
Expand Down
5 changes: 2 additions & 3 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
#include <QTimer>
#include <QByteArray>
#include "qcustomplot.h"
//#include "serialport.h"
#include "qextserialport.h"
#include "serialport.h"
#include "packetinterface.h"
#include "serialization.h"

Expand Down Expand Up @@ -96,7 +95,7 @@ private slots:

private:
Ui::MainWindow *ui;
QextSerialPort *mPort;
SerialPort *mPort;
QTimer *mTimer;
QLabel *mStatusLabel;
int mStatusInfoTime;
Expand Down
29 changes: 11 additions & 18 deletions mrichtextedit.ui
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<string>Undo</string>
</property>
<property name="icon">
<iconset>
<iconset theme="edit-undo">
<normaloff/>
</iconset>
</property>
Expand All @@ -109,7 +109,7 @@
<string>Redo</string>
</property>
<property name="icon">
<iconset>
<iconset theme="edit-redo">
<normaloff/>
</iconset>
</property>
Expand All @@ -133,7 +133,7 @@
<string>Cut</string>
</property>
<property name="icon">
<iconset>
<iconset theme="edit-cut">
<normaloff/>
</iconset>
</property>
Expand All @@ -157,7 +157,7 @@
<string>Copy</string>
</property>
<property name="icon">
<iconset>
<iconset theme="edit-copy">
<normaloff/>
</iconset>
</property>
Expand All @@ -181,7 +181,7 @@
<string>Paste</string>
</property>
<property name="icon">
<iconset>
<iconset theme="edit-paste">
<normaloff/>
</iconset>
</property>
Expand Down Expand Up @@ -212,7 +212,7 @@
<string>Link</string>
</property>
<property name="icon">
<iconset>
<iconset theme="applications-internet">
<normaloff/>
</iconset>
</property>
Expand Down Expand Up @@ -246,7 +246,7 @@
<string>Bold</string>
</property>
<property name="icon">
<iconset>
<iconset theme="format-text-bold">
<normaloff/>
</iconset>
</property>
Expand All @@ -273,7 +273,7 @@
<string>Italic</string>
</property>
<property name="icon">
<iconset>
<iconset theme="format-text-italic">
<normaloff/>
</iconset>
</property>
Expand All @@ -300,7 +300,7 @@
<string>Underline</string>
</property>
<property name="icon">
<iconset>
<iconset theme="format-text-underline">
<normaloff/>
</iconset>
</property>
Expand Down Expand Up @@ -388,7 +388,7 @@
<string>Decrease indentation</string>
</property>
<property name="icon">
<iconset>
<iconset theme="format-indent-less">
<normaloff/>
</iconset>
</property>
Expand All @@ -412,7 +412,7 @@
<string>Increase indentation</string>
</property>
<property name="icon">
<iconset>
<iconset theme="format-indent-more">
<normaloff/>
</iconset>
</property>
Expand Down Expand Up @@ -551,13 +551,6 @@
<property name="tabChangesFocus">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
Expand Down
47 changes: 0 additions & 47 deletions qextserialport-1.2rc/.gitignore

This file was deleted.

Loading

0 comments on commit 271a73e

Please sign in to comment.