diff --git a/Service/Charger/Codec/Decoder.cs b/Service/Charger/Codec/Decoder.cs index c6612f5..0aaa06d 100644 --- a/Service/Charger/Codec/Decoder.cs +++ b/Service/Charger/Codec/Decoder.cs @@ -10,8 +10,6 @@ using Service.Charger.Msg; using Service.Charger.Msg.Bms; using Service.Charger.Msg.Charger.Req; using Service.Charger.Msg.Charger.Resp; -using Service.Charger.Msg.Host.Req; -using static System.Net.Mime.MediaTypeNames; namespace Service.Charger.Codec; @@ -48,6 +46,11 @@ public class Decoder : ByteToMessageDecoder int frameLength = buffer.GetUnsignedShortLE(buffer.ReaderIndex + frameLengthIndex); //总帧长 int totalFrameLength = delimiterIndex + delimiter.Capacity + 2 + frameLength; + // 最小总帧长过滤 + if (totalFrameLength < 24) + { + return; + } if (buffer.ReadableBytes < totalFrameLength) {