为什么要引入“零”模式,为什么默认值为False?

2024-09-24 00:35:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我不知道为什么pymodbus需要零模式参数?任何用例?似乎通常我们都想得到我们设定的

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


Tags: thetostoremapwhichisaddressmode