void _spManager_NewSerialDataRecieved(object sender, SerialDataEventArgs e) { int flag = 0; if (this.InvokeRequired) { // Using this.Invoke causes deadlock when closing serial port, and BeginInvoke is good practice anyway. this.BeginInvoke(new EventHandler <SerialDataEventArgs>(_spManager_NewSerialDataRecieved), new object[] { sender, e }); return; } string str1 = Encoding.ASCII.GetString(e.Data); RXWINDOW.AppendText(str1); RXWINDOW.ScrollToCaret(); if (RXWINDOW.Text.Contains(',')) { RXWINDOW.Clear(); } if (RXWINDOW.Text.Contains('p')) { flag = 1; } else if (RXWINDOW.Text.Contains('t')) { flag = 2; } else if (RXWINDOW.Text.Contains('e')) { flag = 3; } else if (RXWINDOW.Text.Contains('h')) { flag = 4; } else if (RXWINDOW.Text.Contains('a')) { flag = 5; } else if (RXWINDOW.Text.Contains('o')) { flag = 6; } else if (RXWINDOW.Text.Contains('B')) { flag = 7; } else if (RXWINDOW.Text.Contains('Y')) { flag = 8; } else if (RXWINDOW.Text.Contains('R')) { flag = 9; } if (Defined == false) { MessageBox.Show("error"); } // int count = 0; CheckSerial(sender, e, flag); }
void _spManager_NewSerialDataRecieved(object sender, SerialDataEventArgs e) { int flag = 0; if (this.InvokeRequired) { // Using this.Invoke causes deadlock when closing serial port, and BeginInvoke is good practice anyway. this.BeginInvoke(new EventHandler <SerialDataEventArgs>(_spManager_NewSerialDataRecieved), new object[] { sender, e }); return; } string str1 = Encoding.ASCII.GetString(e.Data); RXWINDOW.AppendText(str1); RXWINDOW.ScrollToCaret(); ////// check for the letter corresponding to each data and set the flag value if (RXWINDOW.Text.Contains(',')) { RXWINDOW.Clear(); } if (RXWINDOW.Text.Contains('P')) { flag = 1; } else if (RXWINDOW.Text.Contains('T')) { flag = 2; } else if (RXWINDOW.Text.Contains('E')) { flag = 3; } else if (RXWINDOW.Text.Contains(':')) { flag = 5; } else if (RXWINDOW.Text.Contains('H')) { flag = 6; } else if (RXWINDOW.Text.Contains('B')) { flag = 7; } else if (RXWINDOW.Text.Contains('Y')) { flag = 8; } else if (RXWINDOW.Text.Contains('R')) { flag = 9; } CheckSerial(sender, e, flag); }
private void DisplayText(object sender, EventArgs e) { RXWINDOW.AppendText(RxString); }