From e370d242f2c83f64b38af9e9ab5e162c9a376197 Mon Sep 17 00:00:00 2001 From: zcn1123 <2363211205@qq.com> Date: Mon, 7 Sep 2020 19:21:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E6=94=B6=E5=BB=B6?= =?UTF-8?q?=E6=97=B6=E4=B8=BA200ms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modbus_TCP/Modbus_TCP_log.txt | 18 ++++++++++++++++++ Modbus_communication/Modbus_TCP/TCP_client.cpp | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Modbus_communication/Modbus_TCP/Modbus_TCP_log.txt b/Modbus_communication/Modbus_TCP/Modbus_TCP_log.txt index 9ee522e..038f01e 100644 --- a/Modbus_communication/Modbus_TCP/Modbus_TCP_log.txt +++ b/Modbus_communication/Modbus_TCP/Modbus_TCP_log.txt @@ -34,3 +34,21 @@ 2020-9-5 19:40:41 Send:00 00 00 00 00 06 01 03 00 00 00 0A 2020-9-5 19:40:52 Send:00 00 00 00 00 06 01 03 00 00 00 0A 2020-9-5 19:40:52 Recv:68 74 74 70 3A 2F 2F 77 77 77 2E 63 6D 73 6F 66 74 2E 63 6E +2020-9-7 18:40:38 Send:00 00 00 00 00 06 01 01 00 00 00 01 +2020-9-7 18:40:38 Recv:00 00 00 00 00 04 01 01 01 00 +2020-9-7 18:40:51 Send:00 00 00 00 00 06 01 03 00 00 00 64 +2020-9-7 18:40:51 Recv:00 00 00 00 00 CB 01 03 C8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +2020-9-7 18:41:20 Send:00 00 00 00 00 06 01 03 00 63 00 01 +2020-9-7 18:41:20 Recv:00 00 00 00 00 05 01 03 02 00 00 +2020-9-7 18:41:34 Send:00 00 00 00 00 06 01 03 00 63 00 03 +2020-9-7 18:41:34 Recv:00 00 00 00 00 09 01 03 06 00 00 00 00 00 00 +2020-9-7 18:41:55 Send:00 00 00 00 00 06 01 03 00 63 00 03 +2020-9-7 18:41:55 Recv:00 00 00 00 00 09 01 03 06 00 00 00 00 00 00 +2020-9-7 18:43:7 Send:00 00 00 00 00 06 01 03 00 00 00 01 +2020-9-7 18:44:25 Send:00 00 00 00 00 07 01 0F 00 00 00 01 01 01 +2020-9-7 18:44:25 Recv:00 00 00 00 00 06 01 0F 00 00 00 01 +2020-9-7 18:45:27 Send:00 00 00 00 00 07 01 0F 00 00 00 01 01 01 +2020-9-7 18:46:53 Send:00 00 00 00 00 07 01 0F 00 00 00 01 01 01 +2020-9-7 18:47:2 Recv:00 00 00 00 00 06 01 0F 00 00 00 01 +2020-9-7 18:47:16 Send:00 00 00 00 00 07 01 0F 00 00 00 01 01 01 +2020-9-7 18:47:30 Recv:00 00 00 00 00 06 01 0F 00 00 00 01 diff --git a/Modbus_communication/Modbus_TCP/TCP_client.cpp b/Modbus_communication/Modbus_TCP/TCP_client.cpp index 304aa7f..76b1e4a 100644 --- a/Modbus_communication/Modbus_TCP/TCP_client.cpp +++ b/Modbus_communication/Modbus_TCP/TCP_client.cpp @@ -102,7 +102,7 @@ SOCKET Init_client(string IP, unsigned int Port_number) } cout << "连接TCP从站成功" << endl; TIMEVAL timeout; - timeout.tv_sec = 2000; //ms + timeout.tv_sec = 200; //ms timeout.tv_usec = 0; //us setsockopt(ClientSocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(struct timeval));//设置接收超时时间 return ClientSocket;