SetUInt16() public method

Push the given UInt16 into this buffer at the current position, and then increments the position.
public SetUInt16 ( UInt16 value ) : void
value System.UInt16 The value to be added.
return void
        /// <summary>
        /// Sends Information Report Request.
        /// </summary>
        /// <param name="time">Send time.</param>
        /// <param name="list">List of COSEM object and attribute index to report.</param>
        /// <returns>Report request as byte array.</returns>
        public byte[][] GenerateInformationReport(DateTime time, List <KeyValuePair <GXDLMSObject, int> > list)
        {
            if (list == null || list.Count == 0)
            {
                throw new ArgumentNullException("list");
            }
            GXByteBuffer buff = new GXByteBuffer();

            byte[][] reply;
            if (UseLogicalNameReferencing)
            {
                throw new Exception("Use GenerateEventNotification when Logical Name referencing is used.");
            }
            else
            {
                GXDLMSSNParameters p = new GXDLMSSNParameters(Settings, Command.InformationReport, list.Count, 0xFF, null, buff);
                foreach (KeyValuePair <GXDLMSObject, int> it in list)
                {
                    // Add variable type.
                    buff.SetUInt8(VariableAccessSpecification.VariableName);
                    int sn = it.Key.ShortName;
                    sn += (it.Value - 1) * 8;
                    buff.SetUInt16((UInt16)sn);
                }
                GXCommon.SetObjectCount(list.Count, buff);
                foreach (KeyValuePair <GXDLMSObject, int> it in list)
                {
                    AddData(it.Key, it.Value, buff);
                }
                reply = GXDLMS.GetSnMessages(p);
            }
            return(reply);
        }
Esempio n. 2
0
        /// <summary>
        /// Sends Event Notification or Information Report Request.
        /// </summary>
        /// <param name="time">Send time.</param>
        /// <param name="list">List of COSEM object and attribute index to report.</param>
        /// <returns>Report request as byte array.</returns>
        public byte[][] GenerateReport(DateTime time, List <KeyValuePair <GXDLMSObject, int> > list)
        {
            if (list == null || list.Count == 0)
            {
                throw new ArgumentNullException("list");
            }
            if (UseLogicalNameReferencing && list.Count != 1)
            {
                throw new ArgumentException("Only one object can send with Event Notification request.");
            }

            GXByteBuffer buff = new GXByteBuffer();

            byte[][] reply;
            if (UseLogicalNameReferencing)
            {
                foreach (KeyValuePair <GXDLMSObject, int> it in list)
                {
                    buff.SetUInt16((ushort)it.Key.ObjectType);
                    buff.Set(GXCommon.LogicalNameToBytes(it.Key.LogicalName));
                    buff.SetUInt8((byte)it.Value);
                    AddData(it.Key, it.Value, buff);
                }
                GXDLMSLNParameters p = new GXDLMSLNParameters(Settings, 0, Command.EventNotification, 0, null, buff, 0xff);
                p.time = time;
                reply  = GXDLMS.GetLnMessages(p);
            }
            else
            {
                GXDLMSSNParameters p = new GXDLMSSNParameters(Settings, Command.InformationReport, list.Count, 0xFF, null, buff);
                foreach (KeyValuePair <GXDLMSObject, int> it in list)
                {
                    // Add variable type.
                    buff.SetUInt8(VariableAccessSpecification.VariableName);
                    int sn = it.Key.ShortName;
                    sn += (it.Value - 1) * 8;
                    buff.SetUInt16((UInt16)sn);
                }
                GXCommon.SetObjectCount(list.Count, buff);
                foreach (KeyValuePair <GXDLMSObject, int> it in list)
                {
                    AddData(it.Key, it.Value, buff);
                }
                reply = GXDLMS.GetSnMessages(p);
            }
            return(reply);
        }
Esempio n. 3
0
        /// <summary>
        /// Discover available PLC meters.
        /// </summary>
        /// <returns>Generated bytes.</returns>
        public byte[] DiscoverRequest()
        {
            GXByteBuffer bb = new GXByteBuffer();

            if (settings.InterfaceType != Enums.InterfaceType.Plc &&
                settings.InterfaceType != Enums.InterfaceType.PlcHdlc)
            {
                throw new ArgumentOutOfRangeException("Invalid interface type.");
            }
            if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
            {
                bb.Set(GXCommon.LLCSendBytes);
            }
            bb.SetUInt8((byte)Command.DiscoverRequest);
            bb.SetUInt8(ResponseProbability);
            bb.SetUInt16(AllowedTimeSlots);
            //DiscoverReport initial credit
            bb.SetUInt8(0);
            // IC Equal credit
            bb.SetUInt8(0);
            int    val           = 0;
            int    clientAddress = settings.ClientAddress;
            int    serverAddress = settings.ServerAddress;
            UInt16 da            = settings.Plc.MacDestinationAddress;
            UInt16 sa            = settings.Plc.MacSourceAddress;

            try
            {
                //10.4.6.4 Source and destination APs and addresses of CI-PDUs
                //Client address is No-station in discoverReport.
                if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
                {
                    settings.Plc.InitialCredit         = 0;
                    settings.Plc.CurrentCredit         = 0;
                    settings.Plc.MacSourceAddress      = 0xC01;
                    settings.Plc.MacDestinationAddress = 0xFFF;
                    settings.ClientAddress             = 0x66;
                    // All-station
                    settings.ServerAddress = 0x33FF;
                }
                else
                {
                    val  = settings.Plc.InitialCredit << 5;
                    val |= settings.Plc.CurrentCredit << 2;
                    val |= settings.Plc.DeltaCredit & 0x3;
                    settings.Plc.MacSourceAddress = 0xC00;
                    settings.ClientAddress        = 1;
                    settings.ServerAddress        = 0;
                }
                return(GXDLMS.GetMacFrame(settings, 0x13, (byte)val, bb));
            }
            finally
            {
                settings.ClientAddress             = clientAddress;
                settings.ServerAddress             = serverAddress;
                settings.Plc.MacDestinationAddress = da;
                settings.Plc.MacSourceAddress      = sa;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Register PLC meters.
        /// </summary>
        /// <param name="initiatorSystemTitle">Active initiator systemtitle</param>
        /// <param name="systemTitle"></param>
        /// <returns>Generated bytes.</returns>
        public byte[] RegisterRequest(byte[] initiatorSystemTitle, byte[] systemTitle)
        {
            GXByteBuffer bb = new GXByteBuffer();

            //Control byte.
            bb.SetUInt8((byte)Command.RegisterRequest);
            bb.Set(initiatorSystemTitle);
            //LEN
            bb.SetUInt8(0x1);
            bb.Set(systemTitle);
            //MAC address.
            bb.SetUInt16(MacSourceAddress);
            int val = settings.Plc.InitialCredit << 5;

            val |= settings.Plc.CurrentCredit << 2;
            val |= settings.Plc.DeltaCredit & 0x3;

            int    clientAddress    = settings.ClientAddress;
            int    serverAddress    = settings.ServerAddress;
            UInt16 macSourceAddress = settings.Plc.MacSourceAddress;
            UInt16 macTargetAddress = settings.Plc.MacDestinationAddress;

            try
            {
                //10.4.6.4 Source and destination APs and addresses of CI-PDUs
                //Client address is No-station in discoverReport.
                if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
                {
                    settings.Plc.InitialCredit         = 0;
                    settings.Plc.CurrentCredit         = 0;
                    settings.Plc.MacSourceAddress      = 0xC01;
                    settings.Plc.MacDestinationAddress = 0xFFF;
                    settings.ClientAddress             = 0x66;
                    // All-station
                    settings.ServerAddress = 0x33FF;
                }
                else
                {
                    settings.ClientAddress             = 1;
                    settings.ServerAddress             = 0;
                    settings.Plc.MacSourceAddress      = 0xC00;
                    settings.Plc.MacDestinationAddress = 0xFFF;
                }
                return(GXDLMS.GetMacFrame(settings, 0x13, (byte)val, bb));
            }
            finally
            {
                settings.ClientAddress             = clientAddress;
                settings.ServerAddress             = serverAddress;
                settings.Plc.MacSourceAddress      = macSourceAddress;
                settings.Plc.MacDestinationAddress = macTargetAddress;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Repear call request.
        /// </summary>
        /// <returns>Generated bytes.</returns>
        public byte[] RepeaterCallRequest()
        {
            GXByteBuffer bb = new GXByteBuffer();

            //Control byte.
            bb.SetUInt8((byte)Command.RepeatCallRequest);
            //MaxAdrMac.
            bb.SetUInt16(0x63);
            //Nb_Tslot_For_New
            bb.SetUInt8(0);
            //Reception-Threshold default value
            bb.SetUInt8(0);
            return(GXDLMS.GetMacFrame(settings, 0x13, 0xFC, bb));
        }
        /// <summary>
        /// Sends Event Notification Request.
        /// </summary>
        /// <param name="time">Send time.</param>
        /// <param name="item">COSEM object and attribute index to report.</param>
        /// <returns>Report request as byte array.</returns>
        public byte[][] GenerateEventNotification(DateTime time, KeyValuePair <GXDLMSObject, int> item)
        {
            GXByteBuffer buff = new GXByteBuffer();

            byte[][] reply;
            if (UseLogicalNameReferencing)
            {
                buff.SetUInt16((ushort)item.Key.ObjectType);
                buff.Set(GXCommon.LogicalNameToBytes(item.Key.LogicalName));
                buff.SetUInt8((byte)item.Value);
                AddData(item.Key, item.Value, buff);
                GXDLMSLNParameters p = new GXDLMSLNParameters(null, Settings, 0, Command.EventNotification, 0, null, buff, 0xff, Command.None);
                p.time = time;
                reply  = GXDLMS.GetLnMessages(p);
            }
            else
            {
                throw new Exception("Use GenerateInformationReport when Short Name referencing is used.");
            }
            return(reply);
        }
Esempio n. 7
0
        private static void HandleReadDataBlockAccess(
            GXDLMSSettings settings, GXDLMSServer server,
            Command command, GXByteBuffer data, int cnt, GXByteBuffer replyData, GXDLMSTranslatorStructure xml)
        {
            GXByteBuffer bb          = new GXByteBuffer();
            byte         lastBlock   = data.GetUInt8();
            UInt16       blockNumber = data.GetUInt16();

            if (xml != null)
            {
                if (command == Command.WriteResponse)
                {
                    xml.AppendStartTag(TranslatorTags.WriteDataBlockAccess);
                }
                else
                {
                    xml.AppendStartTag(TranslatorTags.ReadDataBlockAccess);
                }
                xml.AppendLine("<LastBlock Value=\"" + xml.IntegerToHex(lastBlock, 2) + "\" />");
                xml.AppendLine("<BlockNumber Value=\"" + xml.IntegerToHex(blockNumber, 4) + "\" />");
                if (command == Command.WriteResponse)
                {
                    xml.AppendEndTag(TranslatorTags.WriteDataBlockAccess);
                }
                else
                {
                    xml.AppendEndTag(TranslatorTags.ReadDataBlockAccess);
                }
                return;
            }
            if (blockNumber != settings.BlockIndex)
            {
                Debug.WriteLine("handleReadRequest failed. Invalid block number. " + settings.BlockIndex + "/" + blockNumber);
                bb.SetUInt8(ErrorCode.DataBlockNumberInvalid);
                GXDLMS.GetSNPdu(new GXDLMSSNParameters(settings, command, 1, (byte)SingleReadResponse.DataAccessError, bb, null), replyData);
                settings.ResetBlockIndex();
                return;
            }
            int  count = 1;
            byte type  = (byte)DataType.OctetString;

            if (command == Command.WriteResponse)
            {
                count = GXCommon.GetObjectCount(data);
                type  = data.GetUInt8();
            }
            int size     = GXCommon.GetObjectCount(data);
            int realSize = data.Size - data.Position;

            if (count != 1 || type != (byte)DataType.OctetString || size != realSize)
            {
                Debug.WriteLine("handleGetRequest failed. Invalid block size.");
                bb.SetUInt8(ErrorCode.DataBlockUnavailable);
                GXDLMS.GetSNPdu(new GXDLMSSNParameters(settings, command, cnt, (byte)SingleReadResponse.DataAccessError, bb, null), replyData);
                settings.ResetBlockIndex();
                return;
            }
            if (server.transaction == null)
            {
                server.transaction = new GXDLMSLongTransaction(null, command, data);
            }
            else
            {
                server.transaction.data.Set(data);
            }
            if (lastBlock == 0)
            {
                bb.SetUInt16(blockNumber);
                settings.IncreaseBlockIndex();
                if (command == Command.ReadResponse)
                {
                    type = (byte)SingleReadResponse.BlockNumber;
                }
                else
                {
                    type = (byte)SingleWriteResponse.BlockNumber;
                }
                GXDLMS.GetSNPdu(new GXDLMSSNParameters(settings, command, cnt, type, null, bb), replyData);
                return;
            }
            else
            {
                if (server.transaction != null)
                {
                    data.Size = 0;
                    data.Set(server.transaction.data);
                    server.transaction = null;
                }
                if (command == Command.ReadResponse)
                {
                    HandleReadRequest(settings, server, data, replyData, xml);
                }
                else
                {
                    HandleWriteRequest(settings, server, data, replyData, xml);
                }
                settings.ResetBlockIndex();
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Convert HDLC address to bytes.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="size">Address size in bytes.</param>
 /// <returns></returns>
 private static byte[] GetHdlcAddressBytes(int value, byte size)
 {
     Object tmp = GetHhlcAddress(value, size);
     GXByteBuffer bb = new GXByteBuffer();
     if (tmp is byte)
     {
         bb.SetUInt8((byte)tmp);
     }
     else if (tmp is UInt16)
     {
         bb.SetUInt16((UInt16)tmp);
     }
     else if (tmp is UInt32)
     {
         bb.SetUInt32((UInt32)tmp);
     }
     else
     {
         throw new ArgumentException("Invalid address type.");
     }
     return bb.Array();
 }
Esempio n. 9
0
 static int AppendMultipleSNBlocks(GXDLMSSNParameters p, GXByteBuffer header, GXByteBuffer reply)
 {
     bool ciphering = p.settings.Cipher != null && p.settings.Cipher.Security != Gurux.DLMS.Enums.Security.None;
     int hSize = reply.Size + 3;
     if (header != null)
     {
         hSize += header.Size;
     }
     //Add LLC bytes.
     if (p.command == Command.WriteRequest ||
             p.command == Command.ReadRequest)
     {
         hSize += 1 + GXCommon.GetObjectCountSizeInBytes(p.count);
     }
     int maxSize = p.settings.MaxPduSize - hSize;
     if (ciphering)
     {
         maxSize -= CipheringHeaderSize;
         if (p.settings.InterfaceType == InterfaceType.HDLC)
         {
             maxSize -= 3;
         }
     }
     maxSize -= GXCommon.GetObjectCountSizeInBytes(maxSize);
     if (p.data.Size - p.data.Position > maxSize)
     {
         //More blocks.
         reply.SetUInt8(0);
     }
     else
     {
         //Last block.
         reply.SetUInt8(1);
         maxSize = p.data.Size - p.data.Position;
     }
     //Add block index.
     reply.SetUInt16(p.blockIndex);
     if (p.command == Command.WriteRequest)
     {
         ++p.blockIndex;
         GXCommon.SetObjectCount(p.count, reply);
         reply.SetUInt8(DataType.OctetString);
     }
     if (p.command == Command.ReadRequest)
     {
         ++p.blockIndex;
     }
     if (header != null)
     {
         GXCommon.SetObjectCount(maxSize + header.Size, reply);
         reply.Set(header);
     }
     else
     {
         GXCommon.SetObjectCount(maxSize, reply);
     }
     return maxSize;
 }
Esempio n. 10
0
 ///<summary>
 ///Generates an acknowledgment message, with which the server is informed to send next packets.
 ///</summary>
 ///<param name="type">
 /// Frame type.
 /// </param>
 ///<returns>
 ///Acknowledgment message as byte array.
 ///</returns>
 internal static byte[] ReceiverReady(GXDLMSSettings settings, RequestTypes type)
 {
     if (type == RequestTypes.None)
     {
         throw new ArgumentException("Invalid receiverReady RequestTypes parameter.");
     }
     // Get next frame.
     if ((type & RequestTypes.Frame) != 0)
     {
         byte id = settings.ReceiverReady();
         return GetHdlcFrame(settings, id, null);
     }
     Command cmd;
     if (settings.UseLogicalNameReferencing)
     {
         if (settings.IsServer)
         {
             cmd = Command.GetResponse;
         }
         else
         {
             cmd = Command.GetRequest;
         }
     }
     else
     {
         if (settings.IsServer)
         {
             cmd = Command.ReadResponse;
         }
         else
         {
             cmd = Command.ReadRequest;
         }
     }
     // Get next block.
     GXByteBuffer bb = new GXByteBuffer(6);
     if (settings.UseLogicalNameReferencing)
     {
         bb.SetUInt32(settings.BlockIndex);
     }
     else
     {
         bb.SetUInt16((UInt16)settings.BlockIndex);
     }
     settings.IncreaseBlockIndex();
     byte[][] reply;
     if (settings.UseLogicalNameReferencing)
     {
         GXDLMSLNParameters p = new GXDLMSLNParameters(settings, cmd, (byte)GetCommandType.NextDataBlock, bb, null, 0xff);
         reply = GXDLMS.GetLnMessages(p);
     }
     else
     {
         GXDLMSSNParameters p = new GXDLMSSNParameters(settings, cmd, 1, (byte)VariableAccessSpecification.BlockNumberAccess, bb, null);
         reply = GXDLMS.GetSnMessages(p);
     }
     return reply[0];
 }
Esempio n. 11
0
        /// <summary>
        /// Get HDLC frame for data.
        /// </summary>
        /// <param name="settings">DLMS settings.</param>
        /// <param name="frame">Frame ID. If zero new is generated.</param>
        /// <param name="data">Data to add.</param>
        /// <returns>HDLC frames.</returns>
        internal static byte[] GetHdlcFrame(GXDLMSSettings settings, byte frame, GXByteBuffer data)
        {
            GXByteBuffer bb = new GXByteBuffer();
            int frameSize, len = 0;
            byte[] primaryAddress, secondaryAddress;
            if (settings.IsServer)
            {
                primaryAddress = GetHdlcAddressBytes(settings.ClientAddress, 0);
                secondaryAddress = GetHdlcAddressBytes(settings.ServerAddress, settings.ServerAddressSize);
            }
            else
            {
                primaryAddress = GetHdlcAddressBytes(settings.ServerAddress, settings.ServerAddressSize);
                secondaryAddress = GetHdlcAddressBytes(settings.ClientAddress, 0);
            }
            // Add BOP
            bb.SetUInt8(GXCommon.HDLCFrameStartEnd);
            frameSize = Convert.ToInt32(settings.Limits.MaxInfoTX);
            // If no data
            if (data == null || data.Size == 0)
            {
                bb.SetUInt8(0xA0);
            }
            else if (data.Size - data.Position <= frameSize)
            {
                // Is last packet.
                bb.SetUInt8(0xA0);
                len = data.Size - data.Position;
            }
            else
            {
                // More data to left.
                bb.SetUInt8(0xA8);
                len = frameSize;
            }
            //Frame len.
            if (len == 0)
            {
                bb.SetUInt8((byte)(5 + primaryAddress.Length + secondaryAddress.Length + len));
            }
            else
            {
                bb.SetUInt8((byte)(7 + primaryAddress.Length + secondaryAddress.Length + len));
            }
            // Add primary address.
            bb.Set(primaryAddress);
            // Add secondary address.
            bb.Set(secondaryAddress);

            //Add frame ID.
            if (frame == 0)
            {
                frame = settings.NextSend();
            }
            bb.SetUInt8(frame);
            // Add header CRC.
            UInt16 crc = GXFCS16.CountFCS16(bb.Data, 1, bb.Size - 1);
            bb.SetUInt16(crc);
            if (len != 0)
            {
                //Add data.
                bb.Set(data, len);
                // Add data CRC.
                crc = GXFCS16.CountFCS16(bb.Data, 1, bb.Size - 1);
                bb.SetUInt16(crc);
            }
            // Add EOP
            bb.SetUInt8(GXCommon.HDLCFrameStartEnd);
            if (data != null)
            {
                //Remove sent data in server side.
                if (settings.IsServer)
                {
                    if (data.Size == data.Position)
                    {
                        data.Clear();
                    }
                    else
                    {
                        data.Move(data.Position, 0, data.Size - data.Position);
                        data.Position = 0;
                    }
                }
            }
            return bb.Array();
        }
Esempio n. 12
0
 /// <summary>
 /// Split DLMS PDU to wrapper frames.
 /// </summary>
 /// <param name="settings">DLMS settings.</param>
 /// <param name="data"> Wrapped data.</param>
 /// <returns>Wrapper frames</returns>
 internal static byte[] GetWrapperFrame(GXDLMSSettings settings, GXByteBuffer data)
 {
     GXByteBuffer bb = new GXByteBuffer();
     // Add version.
     bb.SetUInt16(1);
     if (settings.IsServer)
     {
         bb.SetUInt16((UInt16)settings.ServerAddress);
         bb.SetUInt16((UInt16)settings.ClientAddress);
     }
     else
     {
         bb.SetUInt16((UInt16)settings.ClientAddress);
         bb.SetUInt16((UInt16)settings.ServerAddress);
     }
     if (data == null)
     {
         // Data length.
         bb.SetUInt16(0);
     }
     else
     {
         // Data length.
         bb.SetUInt16((UInt16)data.Size);
         // Data
         bb.Set(data);
     }
     //Remove sent data in server side.
     if (settings.IsServer)
     {
         if (data.Size == data.Position)
         {
             data.Clear();
         }
         else
         {
             data.Move(data.Position, 0, data.Size - data.Position);
             data.Position = 0;
         }
     }
     return bb.Array();
 }
 private static void HandleReadDataBlockAccess(
     GXDLMSSettings settings, GXDLMSServer server,
     Command command, GXByteBuffer data, int cnt, GXByteBuffer replyData, GXDLMSTranslatorStructure xml)
 {
     GXByteBuffer bb = new GXByteBuffer();
     byte lastBlock = data.GetUInt8();
     UInt16 blockNumber = data.GetUInt16();
     if (xml != null)
     {
         if (command == Command.WriteResponse)
         {
             xml.AppendStartTag(TranslatorTags.WriteDataBlockAccess);
         }
         else
         {
             xml.AppendStartTag(TranslatorTags.ReadDataBlockAccess);
         }
         xml.AppendLine("<LastBlock Value=\"" + xml.IntegerToHex(lastBlock, 2) + "\" />");
         xml.AppendLine("<BlockNumber Value=\"" + xml.IntegerToHex(blockNumber, 4) + "\" />");
         if (command == Command.WriteResponse)
         {
             xml.AppendEndTag(TranslatorTags.WriteDataBlockAccess);
         }
         else
         {
             xml.AppendEndTag(TranslatorTags.ReadDataBlockAccess);
         }
         return;
     }
     if (blockNumber != settings.BlockIndex)
     {
         Debug.WriteLine("handleReadRequest failed. Invalid block number. " + settings.BlockIndex + "/" + blockNumber);
         bb.SetUInt8(ErrorCode.DataBlockNumberInvalid);
         GXDLMS.GetSNPdu(new GXDLMSSNParameters(settings, command, 1, (byte)SingleReadResponse.DataAccessError, bb, null), replyData);
         settings.ResetBlockIndex();
         return;
     }
     int count = 1;
     byte type = (byte)DataType.OctetString;
     if (command == Command.WriteResponse)
     {
         count = GXCommon.GetObjectCount(data);
         type = data.GetUInt8();
     }
     int size = GXCommon.GetObjectCount(data);
     int realSize = data.Size - data.Position;
     if (count != 1 || type != (byte)DataType.OctetString || size != realSize)
     {
         Debug.WriteLine("handleGetRequest failed. Invalid block size.");
         bb.SetUInt8(ErrorCode.DataBlockUnavailable);
         GXDLMS.GetSNPdu(new GXDLMSSNParameters(settings, command, cnt, (byte)SingleReadResponse.DataAccessError, bb, null), replyData);
         settings.ResetBlockIndex();
         return;
     }
     if (server.transaction == null)
     {
         server.transaction = new GXDLMSLongTransaction(null, command, data);
     }
     else
     {
         server.transaction.data.Set(data);
     }
     if (lastBlock == 0)
     {
         bb.SetUInt16(blockNumber);
         settings.IncreaseBlockIndex();
         if (command == Command.ReadResponse)
         {
             type = (byte)SingleReadResponse.BlockNumber;
         }
         else
         {
             type = (byte)SingleWriteResponse.BlockNumber;
         }
         GXDLMS.GetSNPdu(new GXDLMSSNParameters(settings, command, cnt, type, null, bb), replyData);
         return;
     }
     else
     {
         if (server.transaction != null)
         {
             data.Size = 0;
             data.Set(server.transaction.data);
             server.transaction = null;
         }
         if (command == Command.ReadResponse)
         {
             HandleReadRequest(settings, server, data, replyData, xml);
         }
         else
         {
             HandleWriteRequest(settings, server, data, replyData, xml);
         }
         settings.ResetBlockIndex();
     }
 }