private void button2_Click(object sender, EventArgs e) { if (myserialPort != null) { char[] array = new char[4]; myserialPort.ReadTimeout = 10000; try { array[0] = (char)myserialPort.ReadChar(); } catch (Exception) { textBox6.Text = "ReadChar() timeout"; myserialPort = SerialHandle.CloseCom(myserialPort); } string s = new string(array); textBox5.Text = s; } else { //do nothing } }
//public SerialPort MyserialPort1 { get => myserialPort1; set => myserialPort1 = value; } public void button1_Click(object sender, EventArgs e) { string[] value = SerialHandle.FindPorts();; textBox1.Text = value[0]; textBox2.Text = value[1]; }
private void button2_Click_1(object sender, EventArgs e) { myserialPort = SerialHandle.CloseCom(myserialPort); }
private void radioButton2_CheckedChanged(object sender, EventArgs e) { myserialPort = SerialHandle.OpenCom(textBox2.Text, myserialPort); }