• 大小: 5.54M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-04-25
  • 语言: C#
  • 标签: 串口助手  助手  串口  

资源简介


资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace First_Demo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
        }
        /// 
        /// 窗口初始化函数
        /// 

        /// 
        /// 
        private void Form1_Load(object sender EventArgs e)
        {
            comboBox2.Text = “115200“;
            //清空接收区、发送、清空、发送框、接收框不可用
            button3.Enabled = false;
            button4.Enabled = false;
            button5.Enabled = false;
            textBox1_Input.Enabled = false;
            textBox2_Output.Enabled = false;
            Search_Port(serialPort1 comboBox1);
            comboBox1.Text = “COM25“;
            //手动添加的事件处理函数
            serialPort1.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
        }
        /// 
        /// 打开串口
        /// 

        /// 
        /// 
        private void button2_Click(object sender EventArgs e)
        {
            string buffer = comboBox1.Text;//获取控件信息
            if (buffer.Equals(““))//如果buffer数值为空
            {
                MessageBox.Show(“请选择串口“ “提示“);
                return;
            }
            if (serialPort1.IsOpen)//如果串口已经打开
            {
                try
                {
                    button2.Text = “打开串口“;
                    serialPort1.Close();
                    //清空接收区、发送、清空、发送框、接收框不可用
                    button3.Enabled = false;
                    button4.Enabled = false;
                    textBox1_Input.Enabled = false;
                    //扫描可用
                    button1.Enabled = true;
                    //端口号可用
                    comboBox1.Enabled = true;
                    //波特率可用
                    comboBox2.Enabled = true;
                }
                catch { }
                return;
            }
            try
            {
                serialPort1.PortName = comboBox1.Text;//获取端口号
                serialPort1.BaudRate = Convert.ToInt32(comboBox2.Text 10);//获取波特率
                serialPort1.Open();
                button2.Text = “关闭串口“;
                //扫描按键不可用
                button1.Enabled = false;
                //端口号不可用
                comboBox1.Enabled = false;
                //波特率不可用
                comboBox2.Enabled = false;
                //清空接收区、发送、清空、发送框、接收框可用
                button3.Enabled = true;
                button4.Enabled = true;
                button5.Enabled = true;
                textBox1_Input.Enabled = true;
                textBox2_Output.Enabled = true;
            }
            catch
  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\
     目录           0  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\
     文件         900  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo.sln
     目录           0  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\
     文件         182  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\App.config
     文件        4057  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\First_Demo.csproj
     文件       19284  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\Form1.Designer.cs
     文件        9510  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\Form1.cs
     文件     6266109  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\Form1.resx
     文件         500  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\Program.cs
     目录           0  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\Properties\
     文件        1322  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\Properties\AssemblyInfo.cs
     文件        3152  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\Properties\Resources.Designer.cs
     文件        6075  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\Properties\Resources.resx
     文件        1067  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\Properties\Settings.Designer.cs
     文件         242  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\Properties\Settings.settings
     目录           0  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\UI图片\
     文件      775702  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\UI图片\Jellyfish.jpg
     文件      620888  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\UI图片\Tulips.jpg
     文件        4286  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\First_Demo\串口助手.ico
     文件         141  2020-03-16 01:03  C-sharp-serial-port-debugging-assistant-master\C#串口调试助手\删除编译过程文件.bat

评论

共有 条评论