System.IO.BACnet.BacnetMstpProtocolTransport.Send C# (CSharp) Méthode

Send() public méthode

public Send ( byte buffer, int offset, int data_length, BacnetAddress address, bool wait_for_transmission, int timeout ) : int
buffer byte
offset int
data_length int
address BacnetAddress
wait_for_transmission bool
timeout int
Résultat int
        public int Send(byte[] buffer, int offset, int data_length, BacnetAddress address, bool wait_for_transmission, int timeout)
        {
            if (m_TS == -1) throw new Exception("Source address must be set up before sending messages");

            //add to queue
            BacnetNpduControls function = NPDU.DecodeFunction(buffer, offset);
            BacnetMstpFrameTypes frame_type = (function & BacnetNpduControls.ExpectingReply) == BacnetNpduControls.ExpectingReply ? BacnetMstpFrameTypes.FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY : BacnetMstpFrameTypes.FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
            byte[] copy = new byte[data_length + MSTP.MSTP_HEADER_LENGTH + 2];
            Array.Copy(buffer, offset, copy, MSTP.MSTP_HEADER_LENGTH, data_length);
            MessageFrame f = new MessageFrame(frame_type, address.adr[0], copy, data_length);
            m_send_queue.AddLast(f);
            if (m_reply == null)
            {
                m_reply = f;
                m_reply_mutex.Set();
            }

            //wait for message to be sent
            if (wait_for_transmission)
                if (!f.send_mutex.WaitOne(timeout))
                    return -ETIMEDOUT;

            return data_length;
        }