Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ https://github.com/JorgeAparicio/qSerialTerm/wiki

BUILDING
========
Maybe you'll have to compile qwt from sources.
I tested with qwt6 static lib compiled from sources on
Debian Jessie.

$ qmake
$ make
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with qSerialTerm. If not, see <http://www.gnu.org/licenses/>.
*/

#include <QtGui/QApplication>
#include <QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
Expand Down
4 changes: 2 additions & 2 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <QMainWindow>
#include <QActionGroup>

#include <QtAddOnSerialPort/serialport.h>
#include <QtAddOnSerialPort/serialportinfo.h>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>

#include "aboutdialog.h"
#include "imagewidget.h"
Expand Down
35 changes: 17 additions & 18 deletions plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ Plot::Plot(size_t numberOfSamples, qreal minY, qreal maxY, QWidget *parent) :
curve->setData(circularBuffer);
curve->attach(ui->plot);

ui->colorComboBox->addItem("Black", Qt::black);
ui->colorComboBox->addItem("Dark gray", Qt::darkGray);
ui->colorComboBox->addItem("Gray", Qt::gray);
ui->colorComboBox->addItem("Light gray", Qt::lightGray);
ui->colorComboBox->addItem("Red", Qt::red);
ui->colorComboBox->addItem("Green", Qt::green);
ui->colorComboBox->addItem("Blue", Qt::blue);
ui->colorComboBox->addItem("Cyan", Qt::cyan);
ui->colorComboBox->addItem("Magenta", Qt::magenta);
ui->colorComboBox->addItem("Yellow", Qt::yellow);
ui->colorComboBox->addItem("Dark red", Qt::darkRed);
ui->colorComboBox->addItem("Dark green", Qt::darkGreen);
ui->colorComboBox->addItem("Dark blue", Qt::darkBlue);
ui->colorComboBox->addItem("Dark cyan", Qt::darkCyan);
ui->colorComboBox->addItem("Dark magenta", Qt::darkMagenta);
ui->colorComboBox->addItem("Dark yellow", Qt::darkYellow);
ui->colorComboBox->addItem("Black", QColor(Qt::black));
ui->colorComboBox->addItem("Dark gray", QColor(Qt::darkGray));
ui->colorComboBox->addItem("Gray", QColor(Qt::gray));
ui->colorComboBox->addItem("Light gray", QColor(Qt::lightGray));
ui->colorComboBox->addItem("Red", QColor(Qt::red));
ui->colorComboBox->addItem("Green", QColor(Qt::green));
ui->colorComboBox->addItem("Blue", QColor(Qt::blue));
ui->colorComboBox->addItem("Cyan", QColor(Qt::cyan));
ui->colorComboBox->addItem("Magenta", QColor(Qt::magenta));
ui->colorComboBox->addItem("Yellow", QColor(Qt::yellow));
ui->colorComboBox->addItem("Dark red", QColor(Qt::darkRed));
ui->colorComboBox->addItem("Dark green", QColor(Qt::darkGreen));
ui->colorComboBox->addItem("Dark blue", QColor(Qt::darkBlue));
ui->colorComboBox->addItem("Dark cyan", QColor(Qt::darkCyan));
ui->colorComboBox->addItem("Dark magenta", QColor(Qt::darkMagenta));
ui->colorComboBox->addItem("Dark yellow", QColor(Qt::darkYellow));

qsrand(QTime::currentTime().msec());
ui->colorComboBox->setCurrentIndex(qrand() % ui->colorComboBox->count());
Expand Down Expand Up @@ -139,8 +139,7 @@ void Plot::on_gridCheckBox_toggled(bool checked)
{
if (checked) {
grid = new QwtPlotGrid;

grid->setMajPen(QPen(Qt::black, 0, Qt::DashLine));
grid->setMajorPen(QPen(Qt::black, 0, Qt::DashLine));
grid->attach(ui->plot);

ui->plot->replot();
Expand Down
11 changes: 9 additions & 2 deletions qSerialTerm.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets serialport

QWT_ROOT = /media/Datos/Programas/libqwt6

include ( $$QWT_ROOT/features/qwt.prf )

win32 {
CONFIG += serialport qwt
}

unix {
LIBS += -lSerialPort -lqwt
INCLUDEPATH += /usr/include/qwt
LIBS += -lQt5SerialPort
#LIBS += -lqwt
#INCLUDEPATH += /usr/include/qwt
}

TARGET = qSerialTerm
Expand Down
62 changes: 30 additions & 32 deletions serialportwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@

#define REFRESH_RATE_MS 40

QT_USE_NAMESPACE_SERIALPORT

Q_DECLARE_METATYPE(SerialPort::DataBits)
Q_DECLARE_METATYPE(SerialPort::StopBits)
Q_DECLARE_METATYPE(SerialPort::Parity)
Q_DECLARE_METATYPE(SerialPort::FlowControl)
Q_DECLARE_METATYPE(QSerialPort::DataBits)
Q_DECLARE_METATYPE(QSerialPort::StopBits)
Q_DECLARE_METATYPE(QSerialPort::Parity)
Q_DECLARE_METATYPE(QSerialPort::FlowControl)

SerialPortWidget::SerialPortWidget(QWidget *parent) :
QWidget(parent),
Expand All @@ -41,44 +39,44 @@ SerialPortWidget::SerialPortWidget(QWidget *parent) :
ui->setupUi(this);

ui->dataBitsComboBox->addItem(QLatin1String("5"),
SerialPort::Data5);
QSerialPort::Data5);
ui->dataBitsComboBox->addItem(QLatin1String("6"),
SerialPort::Data6);
QSerialPort::Data6);
ui->dataBitsComboBox->addItem(QLatin1String("7"),
SerialPort::Data7);
QSerialPort::Data7);
ui->dataBitsComboBox->addItem(QLatin1String("8"),
SerialPort::Data8);
QSerialPort::Data8);
ui->dataBitsComboBox->setCurrentIndex(-1);


ui->stopBitsComboBox->addItem(QLatin1String("1"),
SerialPort::OneStop);
QSerialPort::OneStop);
ui->stopBitsComboBox->addItem(QLatin1String("1.5"),
SerialPort::OneAndHalfStop);
QSerialPort::OneAndHalfStop);
ui->stopBitsComboBox->addItem(QLatin1String("2"),
SerialPort::TwoStop);
QSerialPort::TwoStop);
ui->stopBitsComboBox->setCurrentIndex(-1);


ui->parityComboBox->addItem(QLatin1String("No"),
SerialPort::NoParity);
QSerialPort::NoParity);
ui->parityComboBox->addItem(QLatin1String("Even"),
SerialPort::EvenParity);
QSerialPort::EvenParity);
ui->parityComboBox->addItem(QLatin1String("Odd"),
SerialPort::OddParity);
QSerialPort::OddParity);
ui->parityComboBox->addItem(QLatin1String("Space"),
SerialPort::SpaceParity);
QSerialPort::SpaceParity);
ui->parityComboBox->addItem(QLatin1String("Mark"),
SerialPort::MarkParity);
QSerialPort::MarkParity);
ui->parityComboBox->setCurrentIndex(-1);


ui->flowControlComboBox->addItem(QLatin1String("No"),
SerialPort::NoFlowControl);
QSerialPort::NoFlowControl);
ui->flowControlComboBox->addItem(QLatin1String("Hardware"),
SerialPort::HardwareControl);
QSerialPort::HardwareControl);
ui->flowControlComboBox->addItem(QLatin1String("Software"),
SerialPort::SoftwareControl);
QSerialPort::SoftwareControl);
ui->flowControlComboBox->setCurrentIndex(-1);
}

Expand All @@ -95,11 +93,11 @@ void SerialPortWidget::write(QByteArray data)

void SerialPortWidget::on_getPortsPushButton_clicked()
{
serialPortInfoList = SerialPortInfo::availablePorts();
serialPortInfoList = QSerialPortInfo::availablePorts();

ui->portComboBox->clear();

foreach(SerialPortInfo entry, serialPortInfoList)
foreach(QSerialPortInfo entry, serialPortInfoList)
ui->portComboBox->addItem(entry.portName());
}

Expand Down Expand Up @@ -130,7 +128,7 @@ void SerialPortWidget::on_openPortPushButton_clicked()
ui->parityComboBox->setCurrentIndex(-1);
ui->flowControlComboBox->setCurrentIndex(-1);
} else {
serialPort = new SerialPort(ui->portComboBox->currentText());
serialPort = new QSerialPort(ui->portComboBox->currentText());

if (serialPort->open(QIODevice::ReadWrite)) {
enableCommunicationSettings();
Expand Down Expand Up @@ -201,7 +199,7 @@ void SerialPortWidget::on_portComboBox_currentIndexChanged(int index)
} else {
ui->openPortPushButton->setEnabled(true);

QList<qint32> baudRateList = serialPortInfoList[index].standardRates();
QList<qint32> baudRateList = serialPortInfoList[index].standardBaudRates();

ui->baudRateComboBox->clear();

Expand All @@ -210,14 +208,14 @@ void SerialPortWidget::on_portComboBox_currentIndexChanged(int index)

ui->baudRateComboBox->setCurrentIndex(-1);

QString vid = serialPortInfoList[index].vendorIdentifier();
QString vid = QString(serialPortInfoList[index].vendorIdentifier());

if (vid.isEmpty())
ui->vidLabel->setText(QLatin1String("-"));
else
ui->vidLabel->setText(QLatin1String("0x") + vid);

QString pid = serialPortInfoList[index].productIdentifier();
QString pid = QString(serialPortInfoList[index].productIdentifier());

if (pid.isEmpty())
ui->pidLabel->setText(QLatin1String("-"));
Expand All @@ -233,7 +231,7 @@ void SerialPortWidget::on_portComboBox_currentIndexChanged(int index)
void SerialPortWidget::on_baudRateComboBox_currentIndexChanged(int index)
{
if (index != -1 && serialPort != 0) {
if(serialPort->setRate(ui->baudRateComboBox->itemData(index).value<int>())) {
if(serialPort->setBaudRate(ui->baudRateComboBox->itemData(index).value<int>())) {
validateCommunicationSettings();

return;
Expand All @@ -251,7 +249,7 @@ void SerialPortWidget::on_baudRateComboBox_currentIndexChanged(int index)
void SerialPortWidget::on_dataBitsComboBox_currentIndexChanged(int index)
{
if (index != -1 && serialPort != 0) {
if(serialPort->setDataBits(ui->dataBitsComboBox->itemData(index).value<SerialPort::DataBits>())) {
if(serialPort->setDataBits(ui->dataBitsComboBox->itemData(index).value<QSerialPort::DataBits>())) {
validateCommunicationSettings();

return;
Expand All @@ -269,7 +267,7 @@ void SerialPortWidget::on_dataBitsComboBox_currentIndexChanged(int index)
void SerialPortWidget::on_stopBitsComboBox_currentIndexChanged(int index)
{
if (index != -1 && serialPort != 0) {
if(serialPort->setStopBits(ui->stopBitsComboBox->itemData(index).value<SerialPort::StopBits>())) {
if(serialPort->setStopBits(ui->stopBitsComboBox->itemData(index).value<QSerialPort::StopBits>())) {
validateCommunicationSettings();

return;
Expand All @@ -287,7 +285,7 @@ void SerialPortWidget::on_stopBitsComboBox_currentIndexChanged(int index)
void SerialPortWidget::on_parityComboBox_currentIndexChanged(int index)
{
if (index != -1 && serialPort != 0) {
if(serialPort->setParity(ui->parityComboBox->itemData(index).value<SerialPort::Parity>())) {
if(serialPort->setParity(ui->parityComboBox->itemData(index).value<QSerialPort::Parity>())) {
validateCommunicationSettings();

return;
Expand All @@ -305,7 +303,7 @@ void SerialPortWidget::on_parityComboBox_currentIndexChanged(int index)
void SerialPortWidget::on_flowControlComboBox_currentIndexChanged(int index)
{
if (index != -1 && serialPort != 0) {
if(serialPort->setFlowControl(ui->flowControlComboBox->itemData(index).value<SerialPort::FlowControl>())) {
if(serialPort->setFlowControl(ui->flowControlComboBox->itemData(index).value<QSerialPort::FlowControl>())) {
validateCommunicationSettings();

return;
Expand Down
8 changes: 4 additions & 4 deletions serialportwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

#include <QWidget>

#include <QtAddOnSerialPort/serialport.h>
#include <QtAddOnSerialPort/serialportinfo.h>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>

#include <QTimer>

Expand Down Expand Up @@ -66,8 +66,8 @@ class SerialPortWidget : public QWidget
void validateCommunicationSettings();

Ui::SerialPortWidget *ui;
QtAddOn::SerialPort::SerialPort *serialPort;
QList<QtAddOn::SerialPort::SerialPortInfo> serialPortInfoList;
QSerialPort *serialPort;
QList<QSerialPortInfo> serialPortInfoList;
QTimer *refreshRateTimer;
bool isThereCommunication;
};
Expand Down