seanpeery / nmodbus

Automatically exported from code.google.com/p/nmodbus
0 stars 0 forks source link

ModbusDataCollection.cs ArgumentOutOfRangeException #22

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Try to set input coil 0 to true on a modbus slave instance.
2.
3.

What is the expected output? What do you see instead?
The coil should be set to true.  Instead an out of range exception is thrown.
the code should be changed to as follows in file 
ModbusDataCollection.cs line 64
"if(index == 0)" should be "if(index < 0)"

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by robma...@gmail.com on 12 Dec 2007 at 10:23

GoogleCodeExporter commented 8 years ago
Actually this is by design. 

1) In a MODBUS PDU data is addressed from 0 to 65535 (0 origin)
2) In the MODBUS data Model each element within a data block is numbered from 1 
to n
(1 origin)
3) .NET collections are of 0 origin 

In order to be true to the Modbus data model I created the 
ModbusDataCollection, a 1
origin collection.

http://modbus.org/docs/Modbus_Application_Protocol_V1_1b.pdf for more details.

Scott

Original comment by sja...@gmail.com on 13 Dec 2007 at 4:53