blj28

导航

send发送完成后测试select函数,每次都要等带20ms 实际数据在2ms内已经返回

在发送完成后加入该函数    tcdrain(ctx->s); 

使用该函数将会增加发送的时间,但是接收的时间会缩短,并未真正改善。

Modbusslave 工具基本上要等待40ms后才能返回,但是modbusascii返回的快一些,工具存在bug

使用真实从站效果好一些

 

 

   

 

 

if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29492
rc is 1 length_to_read is 5
[Sep 5 2024 02:43:49]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29706
rc is 1 length_to_read is 2
[Sep 5 2024 02:43:49]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29781
rc is 1 length_to_read is 8
[Sep 5 2024 02:43:49]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 29809
the last value rc = 1
modbus.c timeuse is 29941
[Sep 5 2024 02:43:49]-[ascii_modbus.c:255->send_msg] 0-------0000-----
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29509
rc is 1 length_to_read is 5
[Sep 5 2024 02:43:49]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29716
rc is 1 length_to_read is 2
[Sep 5 2024 02:43:49]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29791
rc is 1 length_to_read is 8
[Sep 5 2024 02:43:49]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 29818
the last value rc = 1
modbus.c timeuse is 29953
[Sep 5 2024 02:43:49]-[ascii_modbus.c:255->send_msg] 0-------0000-----
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 40501
rc is 1 length_to_read is 5
[Sep 5 2024 02:43:49]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 40647
rc is 1 length_to_read is 2
[Sep 5 2024 02:43:49]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 40707
rc is 1 length_to_read is 8
[Sep 5 2024 02:43:49]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 40734
the last value rc = 1
modbus.c timeuse is 40866
[Sep 5 2024 02:43:49]-[ascii_modbus.c:255->send_msg] 0-------0000-----
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29465
rc is 1 length_to_read is 5
[Sep 5 2024 02:43:49]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29613
rc is 1 length_to_read is 2
[Sep 5 2024 02:43:49]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29670
rc is 1 length_to_read is 8
[Sep 5 2024 02:43:49]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 29697
the last value rc = 1
modbus.c timeuse is 29822
[Sep 5 2024 02:43:49]-[ascii_modbus.c:255->send_msg] 0-------0000-----
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29533
rc is 1 length_to_read is 5
[Sep 5 2024 02:43:49]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29669
rc is 1 length_to_read is 2
[Sep 5 2024 02:43:49]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:43:49]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 29729
rc is 1 length_to_read is 8
[Sep 5 2024 02:43:49]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 29755
the last value rc = 1
modbus.c timeuse is 29879
[Sep 5 2024 02:43:49]-[ascii_modbus.c:255->send_msg] 0-------0000-----
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
****Hold save finish
^C
root@ts600:~/work/ts300# ./111.sh
killall: TS30: no process killed
killall: InvtDaemon.out: no process killed
killall: TS30: no process killed
killall: InvtDaemon.out: no process killed
killall: TS30: no process killed
killall: InvtDaemon.out: no process killed
root@ts600:~/work/ts300# ./111.sh
killall: TS30: no process killed
killall: InvtDaemon.out: no process killed
killall: TS30: no process killed
killall: InvtDaemon.out: no process killed
killall: TS30: no process killed
killall: InvtDaemon.out: no process killed
killall: TS30: no process killed
killall: InvtDaemon.out: no process killed
root@ts600:~/work/ts300# ./start.sh
root@ts600:~/work/ts300#

 


[Sep 5 2024 02:18:23]-[ascii_modbus_master.c:75->Modbus_Ascii_init] ------------------------------------------------------------------------
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 2202
rc is 1 length_to_read is 5
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 2381
rc is 1 length_to_read is 2
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 2441
rc is 1 length_to_read is 8
[Sep 5 2024 02:44:30]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 2467
the last value rc = 1
modbus.c timeuse is 30476
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 6606
rc is 1 length_to_read is 5
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 6838
rc is 1 length_to_read is 8
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 6899
rc is 1 length_to_read is 4
[Sep 5 2024 02:44:30]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 6925
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 153
rc is 1 length_to_read is 5
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 272
rc is 1 length_to_read is 2
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 338
rc is 1 length_to_read is 8
[Sep 5 2024 02:44:30]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 364
the last value rc = 1
modbus.c timeuse is 30324
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 1136
rc is 1 length_to_read is 5
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 1309
rc is 1 length_to_read is 2
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 1367
rc is 1 length_to_read is 8
[Sep 5 2024 02:44:30]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 1393
the last value rc = 1
modbus.c timeuse is 28016
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 4300
rc is 1 length_to_read is 5
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 4443
rc is 1 length_to_read is 2
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 4501
rc is 1 length_to_read is 8
[Sep 5 2024 02:44:30]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 4527
the last value rc = 1
modbus.c timeuse is 30075
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 7251
rc is 1 length_to_read is 5
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 7386
rc is 1 length_to_read is 2
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 7445
rc is 1 length_to_read is 8
[Sep 5 2024 02:44:30]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 7471
the last value rc = 1
modbus.c timeuse is 29885
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 98
rc is 1 length_to_read is 5
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 216
rc is 1 length_to_read is 2
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 285
rc is 1 length_to_read is 8
[Sep 5 2024 02:44:30]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 312
the last value rc = 1
modbus.c timeuse is 29778
if (msg_type ==1) p_tv.tv_usec is 1
while (length_to_read != 0) p_tv.tv_usec is 0
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 1487
rc is 1 length_to_read is 5
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 1935
rc is 1 length_to_read is 2
[Sep 5 2024 02:44:30]-[ascii_modbus.c:620->_ascii_modbus_receive_msg] tv.tv_sec =0,tv.tv_usec =500000 msg_type =1
while (length_to_read != 0) p_tv.tv_usec is 500000
[Sep 5 2024 02:44:30]-[ascii_modbus.c:497->_ascii_modbus_receive_msg] ===========timeuse is 2096
rc is 1 length_to_read is 8
[Sep 5 2024 02:44:30]-[ascii_modbus.c:649->_ascii_modbus_receive_msg] timeuse is 2126
the last value rc = 1
modbus.c timeuse is 28711
if (msg_type ==1) p_tv.tv_usec is 1

posted on 2024-09-05 18:28  bailinjun  阅读(9)  评论(0编辑  收藏  举报