Modbus 增加Decode

master
lxw 5 months ago
parent 5ea3ebc9dc
commit 24d08a2e3d

@ -8,6 +8,12 @@ public static class ModbusDecoder
{ {
private static readonly ILog Log = LogManager.GetLogger(typeof(ModbusDecoder)); private static readonly ILog Log = LogManager.GetLogger(typeof(ModbusDecoder));
public static T Decode<T>(byte[] bytes) where T : class, new()
{
T t = new T();
return Decode<T>(bytes, t);
}
public static T Decode<T>(byte[] bytes, T t) where T : class, new() public static T Decode<T>(byte[] bytes, T t) where T : class, new()
{ {
var fields = t.GetType().GetProperties() var fields = t.GetType().GetProperties()

Loading…
Cancel
Save