Skip to content

Commit f829edd

Browse files
committed
Add icon, serial write return bool
1 parent 2d617c2 commit f829edd

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

mainwindow.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ MainWindow::MainWindow(QWidget *parent)
1111

1212
core = new Core();
1313

14-
15-
1614
core->start();
1715
QObject::connect(core, &Core::appendReceivedData, this, &MainWindow::displayData);
1816

1917
updateSerialPortsFuture = QtConcurrent::run(this, &MainWindow::updateSerialPortsNames);
18+
19+
setWindowIcon(QIcon("ShellerIcon.ico"));
2020
}
2121

2222
MainWindow::~MainWindow()
@@ -91,15 +91,22 @@ void MainWindow::on_pushButton_2_clicked()
9191

9292
void MainWindow::on_clearButton_clicked()
9393
{
94-
ui->transmitHexLine->setText("00 00 00 00 00 00 00 00");
94+
ui->transmitHexLine->setText("");
9595
}
9696

97-
9897
void MainWindow::on_pushButton_4_clicked()
9998
{
10099
QString values = ui->transmitHexLine->text();
100+
if (values.length()) {
101+
QStringList valuesList = values.split(QRegExp("\\s+"));
101102

102-
//прочитать все int с строки
103+
QByteArray numbers;
104+
for(auto &el: valuesList) {
105+
numbers.push_back(el.toUInt());
106+
}
107+
108+
core->getSerial()->write(numbers);
109+
}
103110

104111
}
105112

mainwindow.ui

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
<item>
156156
<widget class="QLineEdit" name="transmitHexLine">
157157
<property name="text">
158-
<string>00 00 00 00 00 00 00 00</string>
158+
<string/>
159159
</property>
160160
</widget>
161161
</item>

serialport.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ QByteArray SerialPort::read()
8383
return data;
8484
}
8585

86-
void SerialPort::write(QByteArray &data)
86+
bool SerialPort::write(QByteArray &data)
8787
{
88-
qDebug() << "Push";
89-
transmittQueue.push_back(data);
88+
if (data.length() > 0 && data.length() <= SHELLER_USEFULL_DATA_LENGTH) {
89+
transmittQueue.push_back(data);
90+
return true;
91+
}
92+
93+
return false;
9094
}
9195

9296
bool SerialPort::isEmpty()

serialport.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SerialPort : public QThread
2828
void disconnect();
2929

3030
QByteArray read();
31-
void write(QByteArray &data);
31+
bool write(QByteArray &data);
3232
bool isEmpty();
3333

3434
public slots:

0 commit comments

Comments
 (0)