diff --git a/Plugins/Drivers/PLC.ModBusMaster/DeviceModBusMaster.cs b/Plugins/Drivers/PLC.ModBusMaster/DeviceModBusMaster.cs index 0ec7fa6..6e4e210 100644 --- a/Plugins/Drivers/PLC.ModBusMaster/DeviceModBusMaster.cs +++ b/Plugins/Drivers/PLC.ModBusMaster/DeviceModBusMaster.cs @@ -631,7 +631,9 @@ namespace PLC.ModBusMaster break; case DataTypeEnum.Float: var f = float.Parse(ioArg.Value.ToString()); - ModBusDataConvert.SetReal(shortArray, 0, f); + var fValue = BitConverter.SingleToUInt32Bits(f); + shortArray[1] = (ushort)(fValue & 0xffff); + shortArray[0] = (ushort)(fValue >> 16 & 0xffff); toWriteArray = ChangeBuffersOrder(shortArray, ioArg.EndianType); await _master.WriteMultipleRegistersAsync(slaveAddress, address, toWriteArray); break; diff --git a/Plugins/Plugin/DeviceThread.cs b/Plugins/Plugin/DeviceThread.cs index 5047fd5..74364ba 100644 --- a/Plugins/Plugin/DeviceThread.cs +++ b/Plugins/Plugin/DeviceThread.cs @@ -289,7 +289,8 @@ namespace Plugin { Address = deviceVariable.DeviceAddress, Value = para.Value, - ValueType = deviceVariable.DataType + ValueType = deviceVariable.DataType, + EndianType = deviceVariable.EndianType }; var writeResponse = Driver .WriteAsync(e.RequestId, deviceVariable.Method, ioArgModel).Result;