<gh_stars>0
from pymodbus.payload import BinaryPayloadDecoder
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
import vars

client = ModbusClient(vars.ip, vars.porta)
client.connect()

if not client.connect():
    if not client.connect():
        pass
if client.connect():
    print('Conectado')

    result = client.read_holding_registers(vars.adress, vars.cont, unit=1)
    decoder = BinaryPayloadDecoder.fromRegisters(result.registers)
    print(decoder.decode_16bit_int())

else:
    print('Não conectou')
from pymodbus.payload import BinaryPayloadDecoder
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
import vars

client = ModbusClient(vars.ip, vars.porta)
client.connect()

if not client.connect():
    if not client.connect():
        pass
if client.connect():
    print('Conectado')

    result = client.read_holding_registers(vars.adress, vars.cont, unit=1)
    decoder = BinaryPayloadDecoder.fromRegisters(result.registers)
    print(decoder.decode_16bit_int())

else:
    print('Não conectou')