diff --git a/Service/Charger/Codec/Decoder.cs b/Service/Charger/Codec/Decoder.cs index 0aaa06d..6704736 100644 --- a/Service/Charger/Codec/Decoder.cs +++ b/Service/Charger/Codec/Decoder.cs @@ -58,10 +58,18 @@ public class Decoder : ByteToMessageDecoder return; } - ASDU asdu = Parse(buffer, totalFrameLength, out var data); - Log.Info($"receive {JsonConvert.SerializeObject(asdu)}:{data} from {ChannelUtils.GetAttr(context.Channel, ChargerConst.ChargerSn)}"); - output.Add(asdu); - buffer.Clear(); + byte[]? data = null; + try + { + ASDU asdu = Parse(buffer, totalFrameLength, out data); + Log.Info($"receive {JsonConvert.SerializeObject(asdu)}:{data} from {ChannelUtils.GetAttr(context.Channel, ChargerConst.ChargerSn)}"); + output.Add(asdu); + buffer.Clear(); + } + catch (Exception e) + { + Log.Error($"decode fail msg={BitUtls.BytesToHexStr(data)}"); + } } } @@ -244,4 +252,4 @@ public class Decoder : ByteToMessageDecoder return asdu; } -} \ No newline at end of file +}