1

I have a Modbus RTU device that has information stored within non-standard data addresses.

For example, it stores read values (32-bit IEEE-754 float, converter link) in register number 1003 - 1004.

I think this means I can no longer use standard Python + Modbus RTU libraries like modbus-tk and pymodbus.

What can be done in this situation?


Device Specifics

  • Device: E+E Elektronik's CO2 sensor, series EE872
  • User Manual (section 5.2 contains Modbus RTU information)
  • Device is plugged into Windows 10 machine with Python 3.6
Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119
  • 1
    You can use pymodbus binary decoder class to convert the 4 registers to float . Refer https://github.com/riptideio/pymodbus/blob/master/examples/common/modbus_payload.py – Sanju Feb 06 '20 at 05:10

1 Answers1

1

You can use different type of data-format with modbus-tk by giving it as optional argument of the execute method

    # Read and write floats
    # master.execute(1, cst.WRITE_MULTIPLE_REGISTERS, starting_address=0, output_value=[3.14], data_format='>f')
    # logger.info(master.execute(1, cst.READ_HOLDING_REGISTERS, 0, 2, data_format='>f'))

The data_format is based on python struct module. Expected values are listed here.

https://docs.python.org/3.7/library/struct.html#format-characters

I hope it helps

luc
  • 41,928
  • 25
  • 127
  • 172