Skip to content

有个方法有bug #1

@The-Naruto

Description

@The-Naruto

ReadStructs方法读取时,读取到的多个点的值都是第一个,
下面是原方法代码:
public T[] ReadStructs(ushort dbNumber, ushort startAddress, int count) where T : struct
{
Type typeFromHandle = typeof(T);
int structSize = S7StructType.GetStructSize(typeFromHandle);
T[] array = new T[count];
for (int i = 0; i < count; i++)
{
byte[] value = ReadBytes(S7MemoryAreaType.DataBlock, dbNumber, startAddress, (ushort)structSize, 0).Value;
object obj = S7StructType.ToStruct(typeFromHandle, value);
if (obj == null)
{
throw new ArgumentNullException("obj");
}

      array[i] = (T)obj;
  }

  return array;

}

其中的startAddress参数是不是应该改成startAddress+structSize *i

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions