pymodbus can't understand the slave's response

518 Views Asked by At

I copied this code into the pymodbus documentation:

from pymodbus.client.sync import ModbusSerialClient

client = ModbusSerialClient(
    method='rtu',
    port='com3',
    baudrate=9600,
    timeout=3,
    parity='N',
    stopbits=1,
    bytesize=8
)

if client.connect():  # Trying for connect to Modbus Server/Slave
        '''Reading from a holding register with the below content.'''
    res = client.read_input_registers(address=0, count=3, unit=1)

    if not res.isError():
        print(res)
        print(res.registers)
    else:
        print(res)

else:
    print('Cannot connect to the Modbus Server/Slave')

In case I'm reading a temperature sensor, in modscan the response I have is 27C°

The answer I'm getting is this: ReadInputRegistersResponse (3) [1, 4, 1]

The answer doesn't mean anything to me, do I have to convert the answer?

0

There are 0 best solutions below