title: Pymodbus Read/Write Floats (REAL)
body: <p>I have modbus mapping setup in my AB Micro820 PLC.  I have an array in 40001 for writing, and one in 42001 for reading.  Both are 200 elements and REAL type (32-bit float).  I can write and read currently, so I know the code works, just incorrectly.  The values are read/wrote as very small values (i.e. 4.58577478E-19).  Can anyone point me in the right direction?</p>
  
  <pre><code>#!/usr/bin/env python
  
  from pymodbus.constants import Endian
  from pymodbus.payload import BinaryPayloadDecoder
  from pymodbus.payload import BinaryPayloadBuilder
  from pymodbus.client.sync import ModbusTcpClient
  
  import logging
  logging.basicConfig()
  log = logging.getLogger()
  log.setLevel(logging.INFO)
  
  ip_address = "192.168.2.101"
  
  client = ModbusTcpClient(ip_address)
  if client.connect():    # connection is OK
      # write float
      builder = BinaryPayloadBuilder(endian=Endian.Little)
      builder.add_32bit_float(77.77)
      payload = builder.build()
      result  = client.write_registers(1, payload, skip_encode=True)
      # read floats
      result  = client.read_holding_registers(2001, 4)
      decoder = BinaryPayloadDecoder.fromRegisters(result.registers, endian=Endian.Little)
      print "read_holding_registers: " + str(decoder.decode_32bit_float())
  
      client.close()
  </code></pre>