Exemplo n.º 1
0
        private void button8_Click(object sender, EventArgs e)//回环测试
        {
            byte[] TXBuffer = System.Text.Encoding.GetEncoding("GB2312").GetBytes(textBox3.Text);
            byte[] RXBuffer = new byte[100];
            textBox4.Text = null;
            Application.DoEvents();
            int    Length = Usart.SendDataOne(Value.serialPort1, TXBuffer, TXBuffer.Length, ref RXBuffer, 100);
            string String = System.Text.Encoding.GetEncoding("GB2312").GetString(RXBuffer);

            textBox4.Text = String;
        }
Exemplo n.º 2
0
        private void button8_Click(object sender, EventArgs e)//回环测试
        {
            byte[] TXBuffer = System.Text.Encoding.ASCII.GetBytes(textBox3.Text);
            byte[] RXBuffer = new byte[100];
            pictureBox1.Image = Properties.Resources.Close;
            textBox4.Text     = null;
            Application.DoEvents();
            int    Length = Usart.SendDataOne(serialPort1, TXBuffer, TXBuffer.Length, ref RXBuffer, 100);
            string String = System.Text.Encoding.ASCII.GetString(RXBuffer);

            if (Length > 0)
            {
                pictureBox1.Image = Properties.Resources.Open;
            }
            textBox4.Text = String;
        }