Modbus Connection to Simulator
I am new to Modbus and Motion Perfect but I am trying to connect the simulator to a server that I would be running on my pc (so far I only want to test the connection to the simulator without any hardware connected).
I set up a minimal server on localhost which does nothing using pyModbusTCP
- from pyModbusTCP.server import ModbusServer
- server = ModbusServer("127.0.0.1", 1234, no_block=True)
- print("Start server...")
- print("Server is online")
- while True:
- print("Shutdown server ...")
- print("Server is offline")
And then I try to connect the simulator to the server by running on Motion Perfect this code:
- IF MODBUS(0, -1, 127,0,0,1,1234, 20)=TRUE THEN
PRINT "Modbus Port Open"
PRINT "Error opening Modbus Port"
But it spits out the "Error opening Modbus Port" error
However I can connect to the server without any errors if I run on python
- client=ModbusClient(host="127.0.0.1", port=502)
Does somebody know what I am doing wrong?