最小总帧长过滤

zw
smartwyy 5 months ago
parent b9c1dc7c71
commit 16a5a7a84d

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

Loading…
Cancel
Save