Question about pyModbus

Hi,

I have build small flask web app to read value in tcp ip localhost.. I am using Simulator Modbus poll & slave to read data, now i've hosted my web app in cPanel, I already did but my app not read data in Modbus poll & slave... how I can make this connection..?

I tried to configure my router for with my public IP and open all ports, but not working... Do I need to use sockets for this to work? or I need anything else to read?

My code:

Python:
from pymodbus.client.sync_diag import ModbusTcpDiagClient
from pymodbus.payload import BinaryPayloadDecoder, BinaryPayloadBuilder
from pymodbus.constants import Endian
client = ModbusTcpDiagClient('my public IP address', port=80)
result = client.read_holding_registers(1, 4, 1)
    if result.isError():
val= request.form.get('txtInput', type=int)

print("Results:", str(result.registers[val])
 
Top