|
|
@@ -1,20 +1,35 @@ |
|
|
|
#include "main.h" |
|
|
|
|
|
|
|
string input() |
|
|
|
{ |
|
|
|
string str; |
|
|
|
cout << "请输入string内容:" << endl; |
|
|
|
getline(cin, str, '\n'); |
|
|
|
cout << str << endl; |
|
|
|
return str; |
|
|
|
} |
|
|
|
|
|
|
|
int main() |
|
|
|
{ |
|
|
|
string IP; |
|
|
|
unsigned int Port_number; |
|
|
|
Input_IP(IP, &Port_number); |
|
|
|
Tcp_client(IP, Port_number); |
|
|
|
//string IP; |
|
|
|
//unsigned int Port_number; |
|
|
|
//Input_IP(IP, &Port_number); |
|
|
|
//Tcp_client(IP, Port_number); |
|
|
|
|
|
|
|
int Function_code; |
|
|
|
while (1) |
|
|
|
{ |
|
|
|
cin >> hex; |
|
|
|
int i = 1; |
|
|
|
printf("功能码 : 0x01 0x03 0x0F 0x10 \n"); |
|
|
|
printf("说明 : 读线圈 读寄存器 写多个线圈 写多个寄存器\n"); |
|
|
|
do |
|
|
|
{ |
|
|
|
if (i == 1) |
|
|
|
{ |
|
|
|
i = 0; |
|
|
|
cout << "请输入选择的功能码:"; |
|
|
|
} |
|
|
|
else |
|
|
|
cout << "输入功能码错误,请重新选择的功能码"; |
|
|
|
cin >> Function_code; |
|
|
|
cin.clear(); |
|
|
|
cin.sync(); |
|
|
|
} while (Function_code != 0x01 && Function_code != 0x03 && Function_code != 0x0F && Function_code != 0x10); |
|
|
|
printf("%02X", Function_code); |
|
|
|
getchar(); |
|
|
|
} |
|
|
|
getchar(); |
|
|
|
return 0; |
|
|
|
} |