Skip to content

Commit

Permalink
Merge pull request #1264 from pkuehnel/fix/modbusLittleEndianValues
Browse files Browse the repository at this point in the history
feat(ModbusClientHandlingService): always handle as big endian
  • Loading branch information
pkuehnel authored May 29, 2024
2 parents ec91d90 + 56bdf6b commit e6d9260
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public async Task Connect(IPEndPoint ipEndPoint, ModbusEndianess endianess, Time
};
ConnectTimeout = (int)connectTimeout.TotalMilliseconds;
logger.LogTrace("ConnectTimeout: {ConnectTimeout}", ConnectTimeout);
base.Connect(ipEndPoint, fluentEndianness);
base.Connect(ipEndPoint, ModbusEndianness.BigEndian);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Net;
using TeslaSolarCharger.Services.Services.Modbus.Contracts;
using TeslaSolarCharger.Shared.Enums;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace TeslaSolarCharger.Services.Services.Modbus;

Expand Down Expand Up @@ -46,7 +45,7 @@ public void RemoveClient(string host, int port)

private static byte[] ConvertToCorrectEndianess(ModbusEndianess endianess, byte[] byteArray)
{
var tempArray = endianess == ModbusEndianess.LittleEndian ? byteArray : byteArray.Reverse().ToArray();
var tempArray = byteArray.Reverse().ToArray();
if (endianess == ModbusEndianess.LittleEndian && tempArray.Length % 4 == 0)
{
var swappedByteArray = new byte[tempArray.Length];
Expand Down

0 comments on commit e6d9260

Please sign in to comment.