Enser45 / free-dotnet-modbus

Automatically exported from code.google.com/p/free-dotnet-modbus
0 stars 0 forks source link

Bug in WRITE_MULTIPLE_REGISTERS case of AdjAndReply function of ModbusSlave #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Write an array of DINTs from the PLC to the .NET application
2. View the Datastore holding registers

What is the expected output? What do you see instead?
Expected that the datastore contains the values sent from the PLC. The 
datastore actually contains the values at every second register. For instance 
if you write 3 DINTs to the registers starting at index 0 then index 0 will be 
correct, index 1 will hold garbage, index 2 will be what should have been in 
index 1, etc.

What version of the product are you using? On what operating system?
0.9 and 1.0. Windows 7 x64

Please provide any additional information below.

The line of code with the issue is:

for (int ii = 0; ii < bc; ii += 2)
     modbus_db.Single(x => x.UnitID == unit_id).HoldingRegisters[sa + (ii / 2)] = ToUInt16(receive_buffer.ToArray(), 6 + (ii / 2));

The fix is:

for (int ii = 0; ii < bc; ii += 2)
     modbus_db.Single(x => x.UnitID == unit_id).HoldingRegisters[sa + (ii / 2)] = ToUInt16(receive_buffer.ToArray(), 6 + ii);

Original issue reported on code.google.com by ty.bur...@gmail.com on 3 Dec 2012 at 10:07

GoogleCodeExporter commented 8 years ago
A similar issue is also found in the READ_WRITE_MULTIPLE_REGISTERS case of the 
same function.

The line of code:

modbus_db.Single(x => x.UnitID == unit_id).HoldingRegisters[sa1 + (ii / 2)] = 
ToUInt16(receive_buffer.ToArray(), 6 + (ii / 2));

Should read:

modbus_db.Single(x => x.UnitID == unit_id).HoldingRegisters[sa1 + (ii / 2)] = 
ToUInt16(receive_buffer.ToArray(), 10 + ii);

Original comment by ty.bur...@gmail.com on 5 Dec 2012 at 1:17

GoogleCodeExporter commented 8 years ago
OK, many thanks!! This is a pre-release of the new version.

Can you test it and give a feedback?

Simone.

Original comment by s.assu...@gmail.com on 10 Dec 2012 at 10:34

Attachments:

GoogleCodeExporter commented 8 years ago
Issue 6 has been merged into this issue.

Original comment by s.assu...@gmail.com on 19 Dec 2012 at 7:44

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
The new version was relesed 2 days ago. 

Give it a try!

Simone.

Original comment by s.assu...@gmail.com on 19 Dec 2012 at 7:46