【发布时间】:2021-02-16 13:52:25
【问题描述】:
我需要使用 ModBus 协议和 Raspberry Pi 与多个模块和设备进行通信。 我在 Raspberry Pi 上使用 PyModBus 来读取/写入 Modbus 功能代码。 (https://pymodbus.readthedocs.io/en/latest/readme.html)
我能够通过 RS485 与设备通信 Modbus RTU,但现在我尝试通过以太网电缆通信 ModbusTCP 并不断遇到以下错误:
import pymodbus
from pymodbus.client.sync import ModbusTcpClient
client = ModbusTcpClient('127.0.0.1')
connection = client.connect()
输出: ERROR.pymodbus.client.sync:连接到(127.0.0.1, 502)失败:[Errno 111] 连接被拒绝
有什么错误提示或解释吗?
【问题讨论】:
标签: raspberry-pi4 modbus-tcp pymodbus