-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserialTab.cpp
47 lines (39 loc) · 1002 Bytes
/
serialTab.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "serialTab.h"
#include "ui_serialtab.h"
#include "mainwindow.h"
#include "console.h"
#include "settingsdialog.h"
#include "dataprovider.h"
#include <QMessageBox>
#include <QtSerialPort/QSerialPort>
SerialTab::SerialTab(QWidget *parent) :
QWidget(parent),
ui(new Ui::SerialTab)
{
ui->setupUi(this);
console = ui->plainTextEdit;
//console->setEnabled(false);
connect(DataProvider::getInstance()->serial, SIGNAL(readyRead()), this, SLOT(readData()));
connect(console, SIGNAL(getData(QByteArray)), this, SLOT(writeData(QByteArray)));
}
SerialTab::~SerialTab()
{
delete ui;
}
void SerialTab::setMainWindow(MainWindow* mainWindow_)
{
this->mainWindow = mainWindow_;
}
void SerialTab::writeData(const QByteArray &data)
{
DataProvider::getInstance()->serial->write(data);
}
void SerialTab::readData()
{
QByteArray data = DataProvider::getInstance()->serial->readAll();
console->putData(data);
}
void SerialTab::clear()
{
console->clear();
}