故事到此为止。我使用非常有用的 Johannes YouTube 教程设置了服务器和客户端,最初我在 Raspberry Pi 上使用“localhost”没有任何问题。
https://github.com/Johannes4Linux/Simple-ModbusTCP-Server/blob/master/Simple_ModbusServer.py
然后我尝试使用以太网端口在我的 Windows PC 上设置客户端并连接到服务器 (Pi)。
我使用了 Pi 中“ifconfig”命令中的“inet”IP 地址,而不是 Windows 中“ipconfig”中的地址(它们不同)。
client = ModbusClient(host="192.168.0.16", port=502, debug=True)
client.open()
connect error
False
我试图从 Windows ping 此地址“cmd”,但连接超时。
ping 168.168.0.16
Pinging 168.168.0.16 with 32 bytes of data:
Request timed out.
感觉就像我错过了一些非常明显的东西。如果有人能够帮助我,我将不胜感激。