void _port_DataReceived(object sender, SerialDataReceivedEventArgs e) { StringBuilder sb = new StringBuilder(); if (_asciimode) { for (int i = 0; i < _port.BytesToRead; i++) { sb.Append((char)_port.ReadChar()); } } else { for (int i = 0; i < _port.BytesToRead; i++) { sb.Append(_port.ReadByte()); sb.Append(" "); } } Dispatcher.BeginInvoke(new Action(delegate { TbRecieve.AppendText(sb.ToString()); TbRecieve.ScrollToEnd(); })); }
private void BtnClearRec_Click(object sender, RoutedEventArgs e) { TbRecieve.Clear(); }