Gurux.DLMS.GXDLMS.GetTcpData C# (CSharp) Method

GetTcpData() static private method

Get data from TCP/IP frame.
static private GetTcpData ( GXDLMSSettings settings, GXByteBuffer buff, GXReplyData data ) : void
settings GXDLMSSettings DLMS settings.
buff GXByteBuffer Received data.
data GXReplyData Reply information.
return void
        static void GetTcpData(GXDLMSSettings settings,
                               GXByteBuffer buff, GXReplyData data)
        {
            // If whole frame is not received yet.
            if (buff.Size - buff.Position < 8)
            {
                data.IsComplete = false;
                return;
            }
            int pos = buff.Position;
            int value;
            // Get version
            value = buff.GetUInt16();
            if (value != 1)
            {
                throw new GXDLMSException("Unknown version.");
            }

            // Check TCP/IP addresses.
            CheckWrapperAddress(settings, buff);
            // Get length.
            value = buff.GetUInt16();
            data.IsComplete = !((buff.Size - buff.Position) < value);
            if (!data.IsComplete)
            {
                buff.Position = pos;
            }
            else
            {
                data.PacketLength = buff.Position + value;
            }
        }