From 3dda664f3cf5293f7fec39aee18fb838e1c6e6c7 Mon Sep 17 00:00:00 2001 From: zcn1123 <2363211205@qq.com> Date: Wed, 2 Sep 2020 09:53:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BA=A4=E4=BA=92=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=83=A8=E5=88=86=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modbus_RTU_Salve/common.cpp | 54 ++++++++++++++++--- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/Modbus_communication/Modbus_RTU_Salve/common.cpp b/Modbus_communication/Modbus_RTU_Salve/common.cpp index a3a0f09..a250225 100644 --- a/Modbus_communication/Modbus_RTU_Salve/common.cpp +++ b/Modbus_communication/Modbus_RTU_Salve/common.cpp @@ -217,11 +217,11 @@ BYTE Input_Date_Bits(void) { if (flage == 1) { - printf("请输入串口波特率:"); + printf("请输入有效数据位:"); flage = 0; } else - printf("请重新输入串口波特率:"); + printf("请重新输入有效数据位:"); cin >> Date_Bits; } while (!(Date_Bits == 5 || Date_Bits == 6 || Date_Bits == 7 || Date_Bits == 8)); return Date_Bits; @@ -262,16 +262,16 @@ BYTE Input_Stop_Bits(BYTE Date_Bits) { BYTE Stop_Bits; int flage = 1; - printf("支持的数据位有:5,6,7,8 \n"); + printf("支持的停止位有:0,1,2 \n"); do { if (flage == 1) { - printf("请输入串口波特率:"); + printf("请输入停止位:"); flage = 0; } else - printf("请重新输入串口波特率:"); + printf("请重新输入停止位:"); cin >> Stop_Bits; } while (!Check_Input_Stop_Bits(Date_Bits, Stop_Bits)); return Stop_Bits; @@ -281,9 +281,49 @@ BYTE Input_Stop_Bits(BYTE Date_Bits) * 功能     :  选择校验位 * 描述    : 获取串口通信的校验位 * 输入 : 无 -* 返回值 : Parity数据位 +* 返回值 : Parity 校验位 **********************************************************************************************/ BYTE Input_Parity(void) { + BYTE Parity; + int flage = 1; + printf("支持的校验位有:0- 无校验 1- 奇校验 2- 偶校验 \n"); + do + { + if (flage == 1) + { + printf("请输入校验位:"); + flage = 0; + } + else + printf("请重新输入校验位:"); + cin >> Parity; + } while (!(Parity == 1 || Parity == 0 || Parity == 2)); + return Parity; +} + +/********************************************************************************************* +* 功能     :  生成正常响应报文 +* 描述    : 经过校验后请求报文可以正常响应 +* 输入 : *Requst_Message 请求报文 *Normal_Response_Message 正常响应报文 +* 返回值 : 无 +**********************************************************************************************/ +void Crate_Normal_Response_Message(UINT8 *Requst_Message, UINT8 *Normal_Response_Message) +{ + + +} + +/********************************************************************************************* +* 功能     :  生成异常响应报文 +* 描述    : 经过校验后请求报文可以正常响应 +* 输入 : *Requst_Message 请求报文 *Normal_Response_Message 异常响应报文 +* 返回值 : 无 +**********************************************************************************************/ +void Crate_Abnormal_Response_Message(UINT8 *Requst_Message, UINT8 *Abnormal_Response_Message) +{ + + +} + -} \ No newline at end of file