Ver código fonte

基本功能的实现

master
鹏鹏 李 2 semanas atrás
pai
commit
f6579d3ccf
2 arquivos alterados com 6 adições e 1 exclusões
  1. +1
    -1
      modbus.pro.user
  2. +5
    -0
      widget.cpp

+ 1
- 1
modbus.pro.user Ver arquivo

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.3, 2025-07-25T10:54:01. -->
<!-- Written by QtCreator 4.0.3, 2025-07-25T12:36:51. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>


+ 5
- 0
widget.cpp Ver arquivo

@@ -7,6 +7,7 @@
#include <QString>
#include <QVector>
#include <QMessageBox>
#include <synchapi.h>
#include "crc.h"

Widget::Widget(QWidget *parent) :
@@ -150,6 +151,7 @@ void Widget::on_pushWrite_clicked()
ui->textEdit_2->append("发送报文"+SendCommand.toHex().toUpper());
serialPort->write(SendCommand);

Sleep(100);
timer.isActive();
timer.start(2000); // 2 s 后触发超时

@@ -202,6 +204,7 @@ void Widget::on_pushWrite_clicked()
ui->textEdit_2->append("发送报文"+SendCommand.toHex().toUpper());
serialPort->write(SendCommand);

Sleep(100);
timer.isActive();
timer.start(2000); // 2 s 后触发超时

@@ -353,6 +356,7 @@ void Widget::on_btn_read_clicked()
{
SendCommand.append(0x03);
}

SendCommand.append(ui->lineEdit_stratAddress->text().toInt()/256); //加入起始地址
SendCommand.append(ui->lineEdit_stratAddress->text().toInt()%256);
SendCommand.append(ui->lineEdit_length->text().toInt()/256); //加入长度
@@ -367,6 +371,7 @@ void Widget::on_btn_read_clicked()
ui->textEdit_2->append("发送报文"+SendCommand.toHex().toUpper());
serialPort->write(SendCommand); //发送报文

Sleep(100);
timer.isActive();
timer.start(2000); // 2 s 后触发超时
}

Carregando…
Cancelar
Salvar