2

我不知道为什么 pymodbus 需要 zero_mode 参数?有什么用例吗?似乎通常我们想要得到我们设置的东西。

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

任何人都可以分享一个链接,规范的第 4.4 节在哪里? https://pymodbus.readthedocs.io/en/v1.3.2/examples/synchronous-server.html?highlight=zero_mode

4

0 回答 0