最小总帧长过滤

master
smartwyy 6 months ago
parent b9c1dc7c71
commit 16a5a7a84d

@ -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)
{

Loading…
Cancel
Save