0

我将此代码复制到 pymodbus 文档中:

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')

如果我正在读取温度传感器,在 modscan 中我的响应是 27C°

我得到的答案是:ReadInputRegistersResponse (3) [1, 4, 1]

答案对我没有任何意义,我必须转换答案吗?

4

0 回答 0