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); } ); }
public void AddSentMessage(string message) { SerialCommunication serial = new SerialCommunication(message, SerialCommunication.Type.SEND); SerialCommunicationList.Add(serial); }