diff --git a/modbus.pro.user b/modbus.pro.user index a90843a..7a92d7f 100644 --- a/modbus.pro.user +++ b/modbus.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/widget.cpp b/widget.cpp index 3eb3bf1..6cd13fb 100644 --- a/widget.cpp +++ b/widget.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #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 后触发超时 }