diff --git a/S7.Net.Core/PLC.cs b/S7.Net.Core/PLC.cs index 7936417..f7d32a9 100644 --- a/S7.Net.Core/PLC.cs +++ b/S7.Net.Core/PLC.cs @@ -507,11 +507,16 @@ namespace S7.Net } public object ReadStruct(Type structType, int db) + { + return ReadStruct(structType, db, 0); + } + + public object ReadStruct(Type structType, int db, int startByteAdr) { int numBytes = Types.Struct.GetStructSize(structType); // now read the package - List resultBytes = ReadMultipleBytes(numBytes, db); - + List resultBytes = ReadMultipleBytes(numBytes, db, startByteAdr); + // and decode it return Types.Struct.FromBytes(structType, resultBytes.ToArray()); } @@ -851,9 +856,14 @@ namespace S7.Net /// /// private List ReadMultipleBytes(int numBytes, int db) + { + return ReadMultipleBytes(numBytes, db, 0); + } + + private List ReadMultipleBytes(int numBytes, int db, int startByteAdr) { List resultBytes = new List(); - int index = 0; + int index = startByteAdr; while (numBytes > 0) { var maxToRead = (int)Math.Min(numBytes, 200); diff --git a/S7.Net/PLC.cs b/S7.Net/PLC.cs index 9374fe9..a0b4abf 100644 --- a/S7.Net/PLC.cs +++ b/S7.Net/PLC.cs @@ -507,11 +507,16 @@ namespace S7.Net } public object ReadStruct(Type structType, int db) + { + return ReadStruct(structType, db, 0); + } + + public object ReadStruct(Type structType, int db, int startByteAdr) { int numBytes = Types.Struct.GetStructSize(structType); // now read the package - List resultBytes = ReadMultipleBytes(numBytes, db); - + List resultBytes = ReadMultipleBytes(numBytes, db, startByteAdr); + // and decode it return Types.Struct.FromBytes(structType, resultBytes.ToArray()); } @@ -851,9 +856,14 @@ namespace S7.Net /// /// private List ReadMultipleBytes(int numBytes, int db) + { + return ReadMultipleBytes(numBytes, db, 0); + } + + private List ReadMultipleBytes(int numBytes, int db, int startByteAdr) { List resultBytes = new List(); - int index = 0; + int index = startByteAdr; while (numBytes > 0) { var maxToRead = (int)Math.Min(numBytes, 200);