我遇到 pymodbus TcpClient 超时问题:
import logging
from pymodbus.client.sync import ModbusTcpClient
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)
client = ModbusTcpClient('x.y.z.w', port=yyy)
client.connect()
result = client.read_holding_registers(10, 10)
print(result.registers)
client.close()
Error:
DEBUG:pymodbus.transaction:Running transaction 1
DEBUG:pymodbus.transaction:Transaction failed. (timed out)
ERROR:pymodbus.client.sync:Connection to (x.y.z.w, yyy) failed: [Errno 10061] ╧юфъы■ўхэшх эх єёЄрэютыхэю,
Modpool 与 tiomeot=1 我有错误:
modpoll.exe -c 5 -r 10 -o 1 -p yyy -m tcp x.y.z.w
-- Polling slave... (Ctrl-C to stop)
Reply time-out!
但是当 timeout=10 时,所有商品:
modpoll.exe -c 5 -r 10 -o 10 -p yyy -m tcp x.y.z.w
-- Polling slave... (Ctrl-C to stop)
[10]: 2
[11]: 10
[12]: 10
[13]: 10
- 如何更改 pymodbus TcpClient 中的默认超时?
Try
client = ModbusTcpClient('x.y.z.w', port=yyy, timeout=10)
它适用于 pymodbus 中的 rtu。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)