I'm implementing a Modbus stack for microcontrollers. And I have a question about an implementation detail.
Imagine we have the following Modbus holding registers defined:
<pre>
40001 00 UINT16 regA
40002 01 FLOAT32 regB
40004 03 UINT16 regC
</pre>
What's the expected response to this Read Holding Registers request:
<pre>
01 device address
03 read holding registers
00 00 starting address
00 04 quantity of registers
xx xx crc
</pre>
My first thought is that it would return an 8 byte response, namely [regA regB regC].
But it's also possible that it would return an Illegal Data Address exception because there is no register defined at address 02.
I'm inclined to implement the former. What's the industry consensus on this?
Imagine we have the following Modbus holding registers defined:
<pre>
40001 00 UINT16 regA
40002 01 FLOAT32 regB
40004 03 UINT16 regC
</pre>
What's the expected response to this Read Holding Registers request:
<pre>
01 device address
03 read holding registers
00 00 starting address
00 04 quantity of registers
xx xx crc
</pre>
My first thought is that it would return an 8 byte response, namely [regA regB regC].
But it's also possible that it would return an Illegal Data Address exception because there is no register defined at address 02.
I'm inclined to implement the former. What's the industry consensus on this?