Modbus connection to Simulator?

Modbus connection to Simulator?

Hy everybody
I'm new to the Trio controller and to the Modbus protocol and I am trying to understand how to connect the simulator (I would like to test the program without any hardware connected first) to a server that I would be running on my pc.
So far I have written a minimal python script that opens a server that does nothing

  1. from pyModbusTCP.server import ModbusServer

  2. server = ModbusServer("", 502, no_block=True)

  3. try:
  4.     print("Start server...")
  5.     server.start()
  6.     print("Server is online")
  7.     while True:
  8.         pass

  9. except:
  10.     print("Shutdown server ...")
  11.     server.stop()
  12.     print("Server is offline")
And then I run the following code on Motion Perfect:
  1. IF MODBUS(0, -1, 127,0,0,1,502,20)=TRUE THEN
        PRINT "Modbus Port Open"
        PRINT "Error opening Modbus Port"
However Motion Perfect always fails to connect and the "Error opening Modbus Port" pops up every time.

Does anybody know what I am doing wrong?