FIX byte endianness for S7Net
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user