tcp客户端超时设置

master
rszn 5 months ago
parent 03fb68d76a
commit d9f4e95319

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

@ -3,11 +3,6 @@ using HybirdFrameworkCore.Autofac.Attribute;
using log4net; using log4net;
using Service.Charger.Client; using Service.Charger.Client;
using Service.Charger.Msg.Charger.Resp; 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 namespace Service.Charger.Handler
{ {

Loading…
Cancel
Save