From 8d64bd89fc795c69b65768f6d3b3712c567a41bc Mon Sep 17 00:00:00 2001 From: Michael Croes Date: Tue, 19 Jun 2018 21:24:28 +0200 Subject: [PATCH] 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. --- S7.Net/Types/Int.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/S7.Net/Types/Int.cs b/S7.Net/Types/Int.cs index 468e8b3..5bb218d 100644 --- a/S7.Net/Types/Int.cs +++ b/S7.Net/Types/Int.cs @@ -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; }