Modbus Connection to Simulator
Hi everybody,
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)
- try:
- print("Start server...")
- server.start()
- print("Server is online")
- while True:
- pass
- except:
- print("Shutdown server ...")
- server.stop()
- 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"
modbus_handle=VR(20)
ELSE
PRINT "Error opening Modbus Port"
ENDIF
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)
- client.open()
Does somebody know what I am doing wrong?