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

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

时间:2024-09-05 18:25:46浏览次数:4  
标签:2ms Sep tv 20ms send modbus msg 2024 ascii

在发送完成后加入该函数    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

标签:2ms,Sep,tv,20ms,send,modbus,msg,2024,ascii
From: https://www.cnblogs.com/blj28/p/18399009

相关文章

  • 【Geeksend邮件营销】为什么在发送邮件前要进行邮箱预热?
    发邮件前进行邮箱预热是一个重要的步骤,主要原因有以下几点:提高邮件发送成功率:许多邮件服务提供商(例如Gmail、Outlook等)使用复杂的算法来识别和过滤垃圾邮件或来自不可靠发件人的邮件。而邮箱预热不仅是一个短期的过程,更是一种长期的策略。通过逐步增加邮件发送量和活跃度,你可......
  • C# TcpClient bind,listen,accept,send receive
    //serverusingSystem;usingSystem.Net;usingSystem.Net.Sockets;usingSystem.Text;namespaceConsoleApp63{internalclassProgram{staticvoidMain(string[]args){intport=11000;TcpServerserver......
  • sign_and_send_pubkey: signing failed: agent refused operation
    报错描述ssh连接远程主机时,出现sign_and_send_pubkey:signingfailed:agentrefusedoperation错误,并且还是需要输入密码实验环境Master[root@kvm-master~]#ssh-copy-id-i.ssh/id_rsa.pubroot@kvm-slave/usr/bin/ssh-copy-id:INFO:Sourceofkey(s)tobeinstal......
  • skynet的消息发送:send和call
    skynet是一个轻量级的游戏服务器框架。skynet的核心是服务,服务之间通过消息来通信,消息的来源主要有:定时器网络服务之间的调用(skynet.send或skynet.call)skynet.send和skynet.call假设我们有两个服务A和B,A发了两条消息给B:这里skynet.send和skynet.call的主要区别,在于c......
  • tcp减少2msl的时间
    TCP的2MSL时间通常指的是TIME_WAIT状态的持续时间,它是TCP连接断开过程中的一个阶段,完成以下几个任务:等待丢失的数据包有时间被丢弃。允许老的重复的连接端点(由本地端口号和IP地址组成)被正确处理。解决方案通常涉及调整操作系统层面的设置来减少TIME_WAIT状态的时间......
  • 如何从 python socket.sendmsg 获取套接字 Tx 时间戳
    在阅读此处、此处和此处时,我发现在Linux系统上,您可以通过设置套接字选项来请求接收和传输的数据包的时间戳。我目前可以使用SO_TIMESTAMPNS和SO_TIMESTAMPING来通过recvmsg获取Rx时间戳。使用sendmsg我不知道......
  • android.uid.system sendBroadcast失效的问题
    如果是系统应用android:sharedUserId="android.uid.system"报这个错 Callingamethodinthesystemprocesswithoutaqualifieduser:android.app.ContextImpl.sendBroadcast:1188android.content.ContextWrapper.sendBroadcast:解决添加如下权限<uses-permissionandroi......
  • 通过 Sendgrid API 发送电子邮件时出错
    在我的生产服务器上,我收到以下错误“init()得到了意外的关键字参数'apikey'”开发服务器上的相同代码正在运行。我的生产服务器正在运行gunicorn,我已将环境变量SENDGRID_API_KEY添加到gunicorn.service文件中。我已经重新启动了gunicorn和nginx。我可以看......
  • SpringBoot 依赖之Java Mail Sender邮件发送
    JavaMailSender依赖名称:JavaMailSender功能描述:SendemailusingJavaMailandSpringFramework’sJavaMailSender.使用JavaMail和SpringFramework的JavaMailSender发送电子邮件。<dependency> <groupId>org.springframework.boot</groupId> <artifa......
  • [error] [default] Error sending telemetry FetchError: The pending stream has bee
    我在VSCode使用GithubCopilot时遇到了一个问题。报错信息如下:[error][default]ErrorsendingtelemetryFetchError:Thependingstreamhasbeencanceled(causedby:unabletoverifythefirstcertificate)具体信息:2024-07-2317:44:56.712[error][default]Erro......