tcp客户端超时设置

master
rszn 6 months ago
parent 03fb68d76a
commit d9f4e95319

@ -68,7 +68,7 @@ public class Decoder : ByteToMessageDecoder
byte[]? data = null;
try
{
ASDU asdu = Parse(buffer, totalFrameLength, out data);
ASDU asdu = Parse(buffer, totalFrameLength, delimiter, out data);
Log(chargerSn).Info($"receive {BitUtls.BytesToHexStr(data)}:{JsonConvert.SerializeObject(asdu)} from {chargerSn}");
output.Add(asdu);
buffer.Clear();
@ -118,18 +118,12 @@ public class Decoder : ByteToMessageDecoder
return -1;
}
public ASDU Parse(IByteBuffer byteBuffer, int totalFrameLength, out byte[] data)
public ASDU Parse(IByteBuffer byteBuffer, int totalFrameLength, IByteBuffer delimiter, out byte[] data)
{
data = new byte[totalFrameLength];
byteBuffer.ReadBytes(data);
string ou = string.Empty;
for (int i = 0; i < data.Length; i++)
{
ou += data[i].ToString("X2") + " ";
}
//TODO bug length取值不对上述测试使用
int removeIndex = _delimiters.Length;
int removeIndex = delimiter.Capacity;
ushort cmd = byteBuffer.GetByte(14 + removeIndex);
ushort recordType = byteBuffer.GetByte(23 + removeIndex);

@ -3,11 +3,6 @@ using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Service.Charger.Client;
using Service.Charger.Msg.Charger.Resp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service.Charger.Handler
{

Loading…
Cancel
Save