diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index 71bf528..931401e 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -2860,6 +2860,9 @@ namespace CMS_CORE_Library.S7Net cmsError = null; + // attenzione endianness! invertire byte... + int fixIndex = MemIndex % 2 == 0 ? MemIndex + 1 : MemIndex - 1; + if (bWrite) { // try/catch @@ -2867,7 +2870,7 @@ namespace CMS_CORE_Library.S7Net { byte[] DB_Byte = new byte[1]; DB_Byte[0] = Value; - currPLC.WriteBytes(DataType.DataBlock, MemTable, MemIndex, DB_Byte); + currPLC.WriteBytes(DataType.DataBlock, MemTable, fixIndex, DB_Byte); } catch { @@ -2878,7 +2881,7 @@ namespace CMS_CORE_Library.S7Net { try { - var memByteRead = currPLC.ReadBytes(DataType.DataBlock, MemTable, MemIndex, 1); + var memByteRead = currPLC.ReadBytes(DataType.DataBlock, MemTable, fixIndex, 1); Value = memByteRead[0]; } catch