2

I don't know why pymodbus need zero_mode arguments? Any use case? Seems usually we want to get what we set.

ModbusSequentialDataBlock(0, [1, 2, 3, 4]))
# And we expect get [1, 2, 3, 4] when 
client.read_holding_registers(0, 4)

-

# The slave context can also be initialized in zero_mode which means that a
# request to address(0-7) will map to the address (0-7). The default is
# False which is based on section 4.4 of the specification, so address(0-7)
# will map to (1-8)::
#
#     store = ModbusSlaveContext(..., zero_mode=True)
#---------------------------------------------------------------------------# 
store = ModbusSlaveContext(
    di = ModbusSequentialDataBlock(0, [17]*100),
    co = ModbusSequentialDataBlock(0, [17]*100),
    hr = ModbusSequentialDataBlock(0, [17]*100),
    ir = ModbusSequentialDataBlock(0, [17]*100))

And anyone can share a link, where is section 4.4 of the specification? https://pymodbus.readthedocs.io/en/v1.3.2/examples/synchronous-server.html?highlight=zero_mode

Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150
foxiris
  • 3,125
  • 32
  • 32
  • 1
    The explanation is self explanatory, The Modbus spec could be found [here](http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf). (Refer 4.4 MODBUS Addressing model on page 7), with zero_mode=True, the value at list index 0 is returned when a register is queried at offset 0. With out it, when offset 0 is queried, the value at list index 1 is returned. The examples have same default values set to the entire address range ,hence there is no visible difference. – Sanju Apr 09 '19 at 15:44

0 Answers0