基本信息
源码名称:简单的串口调试助手
源码大小:0.12M
文件格式:.rar
开发语言:C#
更新时间:2016-08-30
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
适合新手入门的串口调试助手

  

  private void button1_Click(object sender, EventArgs e)

       {

           if (flag)

           {

               try

               {

                   button1.Text = "关闭串口";

                   pictureBox1.Visible = true;

                   pictureBox2.Visible = false;

                   serialPort1.PortName = comboBox1.Text;

                   serialPort1.BaudRate = Convert.ToInt32(comboBox2.Text, 10);

                   serialPort1.Parity = 0;

                   serialPort1.DataBits = 8;

                   flag = false;

                   serialPort1.Open();

               }

               catch

               {

                   MessageBox.Show("端口错误,请检查串口", "错误");

                   button1.Text = "打开串口";

                   flag = true;

                   pictureBox1.Visible = false;

                   pictureBox2.Visible = true;

                   serialPort1.Close();

               }

           }

           else

           {

               button1.Text = "打开串口";

               flag = true;

               pictureBox1.Visible = false;

               pictureBox2.Visible = true;

               serialPort1.Close();

           }

       }


       private void button3_Click(object sender, EventArgs e)

       {

           System.Windows.Forms.SaveFileDialog objSave = new System.Windows.Forms.SaveFileDialog();

           objSave.Filter = "(*.txt)|*.txt|" "(*.*)|*.*";


           objSave.FileName = "文件" DateTime.Now.ToString("yyyyMMddHHmm") ".txt";


           if (objSave.ShowDialog() == DialogResult.OK)

           {

               StreamWriter FileWriter = new StreamWriter(objSave.FileName, true); //写文件


               FileWriter.Write(this.textBox1.Text);//将字符串写入

               FileWriter.Close(); //关闭StreamWriter对象

           }

       }