Example #1
0
        private void SendFrame(MessageFrame frame)
        {
            if (SourceAddress == -1 || _port == null)
            {
                return;
            }
            int tx;

            if (frame.Data == null || frame.Data.Length == 0)
            {
                var tmpTransmitBuffer = new byte[MSTP.MSTP_HEADER_LENGTH];
                tx = MSTP.Encode(tmpTransmitBuffer, 0, frame.FrameType, frame.DestinationAddress,
                                 (byte)SourceAddress, 0);
                _port.Write(tmpTransmitBuffer, 0, tx);
            }
            else
            {
                tx = MSTP.Encode(frame.Data, 0, frame.FrameType, frame.DestinationAddress, (byte)SourceAddress,
                                 frame.DataLength);
                _port.Write(frame.Data, 0, tx);
            }
            frame.SendMutex.Set();

            //debug
            if (StateLogging)
            {
                Trace.WriteLine($"         {frame.FrameType} {frame.DestinationAddress.ToString("X2")} ");
            }
        }
Example #2
0
        private void SendFrame(MessageFrame frame)
        {
            if (m_TS == -1 || m_port == null)
            {
                return;
            }
            int tx;

            if (frame.data == null || frame.data.Length == 0)
            {
                byte[] tmp_transmit_buffer = new byte[MSTP.MSTP_HEADER_LENGTH];
                tx = MSTP.Encode(tmp_transmit_buffer, 0, frame.frame_type, frame.destination_address, (byte)m_TS, 0);
                m_port.Write(tmp_transmit_buffer, 0, tx);
            }
            else
            {
                tx = MSTP.Encode(frame.data, 0, frame.frame_type, frame.destination_address, (byte)m_TS, frame.data_length);
                m_port.Write(frame.data, 0, tx);
            }
            frame.send_mutex.Set();

            //debug
            if (StateLogging)
            {
                Trace.WriteLine("         " + frame.frame_type + " " + frame.destination_address.ToString("X2") + " ");
            }
        }
Example #3
0
 private void SendGreeting()
 {
     if (StateLogging)
     {
         Trace.WriteLine("Sending Greeting", null);
     }
     byte[] greeting = { PTP.PTP_GREETING_PREAMBLE1, PTP.PTP_GREETING_PREAMBLE2, 0x43, 0x6E, 0x65, 0x74, 0x0D };        //BACnet\n
     m_port.Write(greeting, 0, greeting.Length);
 }
Example #4
0
        private void SendFrame(MessageFrame frame)
        {
            if (SourceAddress == -1 || _port == null)
            {
                return;
            }
            int tx;

            if (frame.Data == null || frame.Data.Length == 0)
            {
                var tmpTransmitBuffer = new byte[MSTP.MSTP_HEADER_LENGTH];
                tx = MSTP.Encode(tmpTransmitBuffer, 0, frame.FrameType, frame.DestinationAddress,
                                 (byte)SourceAddress, 0);
                _port.Write(tmpTransmitBuffer, 0, tx);
            }
            else
            {
                tx = MSTP.Encode(frame.Data, 0, frame.FrameType, frame.DestinationAddress, (byte)SourceAddress,
                                 frame.DataLength);
                _port.Write(frame.Data, 0, tx);
            }
            frame.SendMutex.Set();
            Log.AddCustomEvent(LagoVista.Core.PlatformSupport.LogLevel.Message, "BacnetMstpProtocol", $"{frame.FrameType} {frame.DestinationAddress:X2}");
        }
 private void SendGreeting()
 {
     Log.AddCustomEvent(LagoVista.Core.PlatformSupport.LogLevel.Message, "BacnetPtpProtocol", "Sending Greeting");
     byte[] greeting = { PTP.PTP_GREETING_PREAMBLE1, PTP.PTP_GREETING_PREAMBLE2, 0x43, 0x6E, 0x65, 0x74, 0x0D }; // BACnet\n
     _port.Write(greeting, 0, greeting.Length);
 }
Example #6
0
 private void SendGreeting()
 {
     Log.Debug("Sending Greeting");
     byte[] greeting = { PTP.PTP_GREETING_PREAMBLE1, PTP.PTP_GREETING_PREAMBLE2, 0x43, 0x6E, 0x65, 0x74, 0x0D }; // BACnet\n
     _port.Write(greeting, 0, greeting.Length);
 }