예제 #1
0
        private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            if (!ArduinoSerialPort.IsOpen)
            {
                return;
            }
            string message;

            try
            {
                message = ArduinoSerialPort.ReadLine().Trim();
            }
            catch (IOException ex)
            {
                Console.WriteLine(ex);
                return;
            }
            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            SerialCommunication serial = new SerialCommunication(message, SerialCommunication.Type.RECIEVE);

            Application.Current.Dispatcher.Invoke(delegate
            {
                SerialCommunicationList.Add(serial);
                arduinoSerialPort.HandleMessage(message);
            }
                                                  );
        }
예제 #2
0
        public void AddSentMessage(string message)
        {
            SerialCommunication serial = new SerialCommunication(message, SerialCommunication.Type.SEND);

            SerialCommunicationList.Add(serial);
        }