Modbus连接失败 [英] Modbus connection failed

查看:1302
本文介绍了Modbus连接失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个连接到Modbus的代码。但是,当我连接它并尝试读取线圈时,它将显示以下错误: -



Hi, I'm writing a code which connect to Modbus. However, when I connect it and try to read coils it will show the error below:-

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond IPAddress





下面是代码我尝试连接和读取线圈: -



Below is the code that i try to connect and read coils:-

for (startAddress = 0; startAddress < 7; startAddress++)
{
    MBmaster = new Master(IPAddress, 502);
    MBmaster.ReadCoils(ID, startAddress, Length);
}





任何想法如何解决这个问题?

谢谢



Any idea how to solve this problem?
Thanks

推荐答案

将MBmaster = new Master(...)移出for循环,设备可能只接受来自一个主机的一个连接。
Move the MBmaster = new Master(...) out of the for loop, the device can probably only accept one connection from one host.


这篇关于Modbus连接失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆