internal static byte[][] GetLnMessages(GXDLMSLNParameters p)
{
GXByteBuffer reply = new GXByteBuffer();
List<byte[]> messages = new List<byte[]>();
byte frame = 0;
if (p.command == Command.Aarq)
{
frame = 0x10;
}
do
{
GetLNPdu(p, reply);
p.lastBlock = true;
if (p.attributeDescriptor == null)
{
++p.settings.BlockIndex;
}
if (p.command == Command.Aarq && p.command == Command.GetRequest)
{
System.Diagnostics.Debug.Assert(!(p.settings.MaxPduSize < reply.Size));
}
while (reply.Position != reply.Size)
{
if (p.settings.InterfaceType == Enums.InterfaceType.WRAPPER)
{
messages.Add(GXDLMS.GetWrapperFrame(p.settings, reply));
}
else if (p.settings.InterfaceType == Enums.InterfaceType.HDLC)
{
messages.Add(GXDLMS.GetHdlcFrame(p.settings, frame, reply));
frame = 0;
}
else if (p.settings.InterfaceType == Enums.InterfaceType.PDU)
{
messages.Add(reply.Array());
frame = 0;
break;
}
else
{
throw new ArgumentOutOfRangeException("InterfaceType");
}
}
reply.Clear();
}
while (p.data != null && p.data.Position != p.data.Size);
return messages.ToArray();
}