From 3b3685c4175cf3abed51a03d95846c4e9a10b126 Mon Sep 17 00:00:00 2001 From: vlad Date: Wed, 2 Feb 2022 13:55:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BD=D0=B5=D0=B2=D0=B5=D1=80=D0=BD=D0=BE?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=B5=D0=BA=D0=BE=D0=B4=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84=D1=80=D0=B5=D0=B9=D0=BC=D0=B0?= =?UTF-8?q?,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BA=D0=BE=D1=80=D0=BE=D1=81=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MainWindow.cpp | 24 ++---------------------- src/MainWindow.ui | 28 +++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index e04e578..ce94068 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -16,25 +16,6 @@ MainWindow::MainWindow(QWidget *parent) ui->log->setReadOnly(true); setWindowTitle("Podval Sniffer soft"); updatePortsList(); - - // это перегон текстовика с заранее сохраненными пакетами -// std::fstream f("test6.txt", std::ios_base::in | std::ios_base::binary); -// if (f.good()) { -// do { -// char chars[22]; -// f.read((char*) chars, 22); -// if (f.good()) { -// for (char c: chars) { -// printf("%c", c); -// putCharToMessage(c); -// } -// } else { -// break; -// } -// } while (!f.eof()); -// ui->log->appendHtml("[INFO] Файл c данными прочитан. Там " + QString::number(messages.size()) + " записей\n"); -// } -// f.close(); } MainWindow::~MainWindow() { @@ -58,7 +39,7 @@ void MainWindow::on_connectButton_clicked() { serial = new QSerialPort(port); connect(serial, &QSerialPort::readyRead, this, &MainWindow::readDataHandler); - serial->setBaudRate(500000); + serial->setBaudRate(ui->speedSelect->currentText().toInt()); serial->setDataBits(QSerialPort::Data8); serial->setFlowControl(QSerialPort::NoFlowControl); serial->setStopBits(QSerialPort::OneStop); @@ -203,8 +184,7 @@ void MainWindow::putCharToMessage(char data) { // теперь саму посылку, она все равно всегда передается как 8 байт for (int i = 0; i < 8; i++) { - automat.message.data[i] = charToNum(automat.text[i + 5]) | - (charToNum(automat.text[i + 4]) << 4); + automat.message.data[i] = charToNum(automat.text[(i << 1) + 5]) | (charToNum(automat.text[(i << 1) + 4]) << 4); } messages.push_back(automat.message); diff --git a/src/MainWindow.ui b/src/MainWindow.ui index bef4697..d51ba01 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -20,7 +20,7 @@ - Выбрать порт + Порт: @@ -34,6 +34,32 @@ + + + + Скорость + + + + + + + + 921600 + + + + + 500000 + + + + + 115200 + + + +