예제 #1
0
        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
            }
        }
예제 #2
0
        //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];
        }
예제 #3
0
 private void button2_Click_1(object sender, EventArgs e)
 {
     myserialPort = SerialHandle.CloseCom(myserialPort);
 }
예제 #4
0
 private void radioButton2_CheckedChanged(object sender, EventArgs e)
 {
     myserialPort = SerialHandle.OpenCom(textBox2.Text, myserialPort);
 }