public void appendValidData(TelemetryPacket packet) { this.BeginInvoke(new EventHandler(delegate { if (packet.isFromPayload()) { String s = packet.toString(); rtbValidPacket.SelectionColor = Color.Blue; rtbValidPacket.AppendText(s); rtbValidPacket.AppendText("\n"); } else { String s = packet.toString(); rtbValidPacket.SelectionColor = Color.Orange; rtbValidPacket.AppendText(s); rtbValidPacket.AppendText("\n"); } })); }
public void logValid(TelemetryPacket packet) { // This method is called when a valid telemetry packet is parsed // This method is called when the serial port recieves data FileStream s1 = new FileStream(logDirPath + "/" + VALID_LOG_FILE_NAME, FileMode.Append); StreamWriter sw = new StreamWriter(s1); try { using (sw) { if (!appendedTimeToValid) { sw.WriteLine("\n**********" + System.DateTime.Now.ToString() + "**********"); appendedTimeToValid = true; } sw.WriteLine(packet.toString()); } } catch (Exception e) { MessageBox.Show("Problem writing log file for valid data: \n" + e.Message); } finally { s1.Close(); } }