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