示例#1
0
        /// <summary>
        /// Send PDU to server
        /// </summary>
        /// <param name="pdu">HARTFrame</param>
        /// <returns>HARTFrame</returns>
        private HARTFrame PDU(HARTFrame pdu)
        {
            var frame = new HARTIPFrame(SequenceNumber, messageID: MessageID.PDU, payload: pdu.Serialize());

            stream.Write(frame.Serialize());
            var buffer = new Byte[256];

            stream.Read(buffer, 0, buffer.Length);
            var response = new HARTFrame(new HARTIPFrame(buffer).GetPayload());

            SequenceNumber++;
            return(response);
        }
示例#2
0
        /// <summary>
        /// Map the network
        /// </summary>
        private void MapNetwork()
        {
            var frame0    = new HARTFrame(new byte[] { 0x00 }, 0);
            var response0 = PDU(frame0);

            GatewayAddress = HARTFrame.GetAddress(response0.GetPayload()[1..3], response0.GetPayload()[9..12]);