As we can see in the following codes:
the function GetWordAt returns a short value from a List<byte> data, as we always do, it should be combine from two continuous bytes, but it is converted from ONE byte.
because I don't know the protocol of PLC S7 200 smart, I don't know it is wrong or just right.
The function is call only once by public static void ParseResponse(byte[] message, int length, DataItem[] dataItems) of class S7WriteMultiple in the program.
While the last function is by public void Write(params DataItem[] dataItems) of class PLC and its async version.
namespace S7.Net.Protocol
{
internal static class Serialization
{
public static ushort GetWordAt(IList<byte> buf, int index)
{
return (ushort)((buf[index] << 8) + buf[index]);
}
...
public static void SetWordAt(ByteArray buffer, int index, ushort value)
{
buffer[index] = (byte)(value >> 8);
buffer[index + 1] = (byte)value;
}