1 private void Comm_DataReceived(object sender, SerialDataReceivedEventArgs e) 2 { 3 int n = comm.BytesToRead; 4 byte[] buf = new byte[n]; 5 comm.Read(buf, 0, n); 6 builder.Clear(); 7 this.Invoke((EventHandler)(delegate 8 { 9 builder.Append(Encoding.UTF8.GetString(buf)); 10 string b = (Encoding.UTF8.GetString(buf)).ToString(); 11 if (b.Contains("T78, 110.2014")) 12 { 13 textBox1.Text = b; 14 textBox2.Text = "pass"; 15 builder.Clear(); 16 Thread.Sleep(1000); 17 comm.Write("T79" + "\r"); 18 } 19 else if (b.Contains("T79,2GIG-b 3.42")) 20 { 21 textBox3.Text = b; 22 textBox4.Text = "pass"; 23 builder.Clear(); 24 Thread.Sleep(1000); 25 comm.Write("T80" + "\r"); 26 else if (b.Contains("T80,13451")) 27 { 28 textBox5.Text = b; 29 textBox6.Text = "pass"; 30 builder.Clear(); 31 Thread.Sleep(1000); 32 comm.Write("T90,2" + "\r"); 33 } 34 35 } 36 。。。。。