Fix byte order when serializing short[] / Int16[]

Values should be written as big-endian, unfortunately the ordering for
short values in an array was little-endian.
This commit is contained in:
Michael Croes
2018-06-19 21:24:28 +02:00
parent 0721b1a84a
commit 8d64bd89fc

View File

@@ -45,8 +45,8 @@ namespace S7.Net.Types
for(int i=0; i< value.Length; i++)
{
bytes[bytesPos++] = (byte)((int)value[i] & 0xFF);
bytes[bytesPos++] = (byte)(((int)value[i] >> 8) & 0xFF);
bytes[bytesPos++] = (byte)((value[i] >> 8) & 0xFF);
bytes[bytesPos++] = (byte) (value[i] & 0xFF);
}
return bytes;
}