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