R
When attempting to read the holding registers using nmodbus net 3.5 I am receiving unexpected errors, only when reading addresses outside of 40001-40008
Code(C# + NModBus Net 3.5):<pre>
byte sid = 1;
ushort saddress = 0;
ushort snumregisters = 8;
ModbusSerialMaster master = ModbusSerialMaster.CreateRtu(port);
ushort[] registers = master.ReadHoldingRegisters(sid, saddress, snumregisters);</pre>
The above code works fine and i get expected results back for the 8 addresses in <i>registers[]</i>, however if i change <i>saddress</i> to <b>50</b> i receive the following errors: *Running the code above on a loop with one second delay*<pre>
Message:: Function code 123 not supported.
Message:: The I/O operation has been aborted because of either a thread exit or an application request.
Message:: Exception of type 'Modbus.SlaveException' was thrown.
Function Code: 131
Exception Code: 2 - The data address received in the query is not an allowable address for the server (or slave). More specifically, the combination of reference number and transfer length is invalid. For a controller with 100 registers, the PDU addresses the first register as 0, and the last one as 99. If a request is submitted with a starting register address of 96 and a quantity of registers of 4, then this request will successfully operate (address-wise at least) on registers 96, 97, 98, 99. If a request is submitted with a starting register address of 96 and a quantity of registers of 5, then this request will fail with Exception Code 0x02 "Illegal Data Address" since it attempts to operate on registers 96, 97, 98, 99 and 100, and there is no register with address 100.
Message:: Function code 0 not supported.
Message:: Checksums failed to match 0, 232, 249 != 0, 232, 249, 255, 155
Message:: Function code 126 not supported.
Message:: Checksums failed to match 243, 239, 245 != 243, 239, 245, 254, 0
</pre>
Code(C# + NModBus Net 3.5):<pre>
byte sid = 1;
ushort saddress = 0;
ushort snumregisters = 8;
ModbusSerialMaster master = ModbusSerialMaster.CreateRtu(port);
ushort[] registers = master.ReadHoldingRegisters(sid, saddress, snumregisters);</pre>
The above code works fine and i get expected results back for the 8 addresses in <i>registers[]</i>, however if i change <i>saddress</i> to <b>50</b> i receive the following errors: *Running the code above on a loop with one second delay*<pre>
Message:: Function code 123 not supported.
Message:: The I/O operation has been aborted because of either a thread exit or an application request.
Message:: Exception of type 'Modbus.SlaveException' was thrown.
Function Code: 131
Exception Code: 2 - The data address received in the query is not an allowable address for the server (or slave). More specifically, the combination of reference number and transfer length is invalid. For a controller with 100 registers, the PDU addresses the first register as 0, and the last one as 99. If a request is submitted with a starting register address of 96 and a quantity of registers of 4, then this request will successfully operate (address-wise at least) on registers 96, 97, 98, 99. If a request is submitted with a starting register address of 96 and a quantity of registers of 5, then this request will fail with Exception Code 0x02 "Illegal Data Address" since it attempts to operate on registers 96, 97, 98, 99 and 100, and there is no register with address 100.
Message:: Function code 0 not supported.
Message:: Checksums failed to match 0, 232, 249 != 0, 232, 249, 255, 155
Message:: Function code 126 not supported.
Message:: Checksums failed to match 243, 239, 245 != 243, 239, 245, 254, 0
</pre>