Added VirtualModbusClient to Common

This commit is contained in:
2025-01-23 22:01:45 +01:00
parent ce3d873cd0
commit fb67e0b77e
14 changed files with 752 additions and 81 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace AMWD.Protocols.Modbus.Common
@@ -12,14 +13,14 @@ namespace AMWD.Protocols.Modbus.Common
Array.Reverse(bytes);
}
public static ushort GetBigEndianUInt16(this byte[] bytes, int offset = 0)
public static ushort GetBigEndianUInt16(this IReadOnlyList<byte> bytes, int offset = 0)
{
byte[] b = bytes.Skip(offset).Take(2).ToArray();
b.SwapBigEndian();
return BitConverter.ToUInt16(b, 0);
}
public static byte[] ToBigEndianBytes(this ushort value)
public static IReadOnlyList<byte> ToBigEndianBytes(this ushort value)
{
byte[] b = BitConverter.GetBytes(value);
b.SwapBigEndian();