资源简介
C#编写的串口调试助手
<--------
很多和我一样学习软件专业的学生,有的时候对一些小项目真的是无可奈何
上次和我同学闲聊,他说C#写一个串口调试助手好难,
见此情景,我就不自觉得也来写了一个,亲测可用
主要功能有:
1.串口设置:
1)接收端口
2)数据位
3)奇偶检验位
4)波特率
5)停止位
6)……
2.执行状态
3.通信测试(HEX发送)
4.接收模式(响应模式、应答模式、HEX显示)
下载须知:需要VS2012版本,及以上

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports; //导入串口的命名空间
namespace _01_SerialPort
{
public partial class Form1 : Form
{
public delegate void showReceiveDelegate(string text); //当采用响应模式,应申明一个委托,实现不同线程的控件实验
SerialPort com = new SerialPort(“COM2“ 9600 Parity.None 8 StopBits.One);//初始化构造函数
public Form1()
{
InitializeComponent();
}
///
/// 窗体加载
///
///
///
private void Form1_Load(object sender EventArgs e)
{
cmbPort.SelectedIndex = 0;
cmbBaudRate.SelectedIndex = 0;
cmbDataBits.SelectedIndex = 0;
cmbStopBits.SelectedIndex = 0;
cmbParity.SelectedIndex = 0;
}
///
/// 串口打开与关闭
///
///
///
private void btnOpen_Click(object sender EventArgs e)
{
if (btnOpen.Text == “打开串口“)
{
try
{
if (!com.IsOpen)
{
com.PortName = cmbPort.Text;
com.BaudRate = int.Parse(cmbBaudRate.Text);
com.DataBits = int.Parse(cmbDataBits.Text);
switch (cmbStopBits.SelectedIndex) {
case 0:
com.StopBits = StopBits.One; break;
case 1:
com.StopBits = StopBits.Two; break;
case 2:
com.StopBits = StopBits.OnePointFive; break;
case 3:
com.StopBits = StopBits.None; break;
}
switch (cmbParity.SelectedIndex)
{
case 0: com.Parity = Parity.None; break;
case 1: com.Parity = Parity.Odd; break;
case 2: com.Parity = Parity.Even; break;
}
com.Open();//打开串口
}
btnOpen.Text = “关闭串口“;
txtStatus.Text = “串口已打开!“;
btnSend.Enabled = true;
if (rbAck.Checked)
btnReceive.Enabled = true; //应答模式,接收按钮有效
}
catch
{ txtStatus.Text = “串口打开错误或串口不存在!“; }
}
else //关闭串口
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 45056 2017-10-26 09:39 01_SerialPort\.vs\01_SerialPort\v15\.suo
文件 0 2017-10-26 09:39 01_SerialPort\.vs\01_SerialPort\v15\Server\sqlite3\db.lock
文件 512000 2017-10-26 09:39 01_SerialPort\.vs\01_SerialPort\v15\Server\sqlite3\storage.ide
文件 3927 2015-03-18 08:57 01_SerialPort\01_SerialPort\01_SerialPort.csproj
文件 17408 2015-04-14 11:51 01_SerialPort\01_SerialPort\bin\Debug\01_SerialPort.exe
文件 32256 2015-04-14 11:51 01_SerialPort\01_SerialPort\bin\Debug\01_SerialPort.pdb
文件 21464 2015-03-18 08:57 01_SerialPort\01_SerialPort\bin\Debug\01_SerialPort.vshost.exe
文件 490 2015-03-18 08:57 01_SerialPort\01_SerialPort\bin\Debug\01_SerialPort.vshost.exe.manifest
文件 10425 2015-04-07 13:26 01_SerialPort\01_SerialPort\Form1.cs
文件 17358 2015-03-18 08:57 01_SerialPort\01_SerialPort\Form1.Designer.cs
文件 5814 2015-03-18 08:57 01_SerialPort\01_SerialPort\Form1.resx
文件 42 2017-10-26 09:39 01_SerialPort\01_SerialPort\obj\Debug\01_SerialPort.csproj.CoreCompileInputs.cache
文件 4302 2015-04-14 11:51 01_SerialPort\01_SerialPort\obj\Debug\01_SerialPort.csproj.FileListAbsolute.txt
文件 905 2015-04-14 11:51 01_SerialPort\01_SerialPort\obj\Debug\01_SerialPort.csproj.GenerateResource.Cache
文件 2157 2015-04-14 11:51 01_SerialPort\01_SerialPort\obj\Debug\01_SerialPort.csprojResolveAssemblyReference.cache
文件 17408 2015-04-14 11:51 01_SerialPort\01_SerialPort\obj\Debug\01_SerialPort.exe
文件 32256 2015-04-14 11:51 01_SerialPort\01_SerialPort\obj\Debug\01_SerialPort.pdb
文件 790 2017-10-26 09:39 01_SerialPort\01_SerialPort\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7248 2017-10-26 09:39 01_SerialPort\01_SerialPort\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 4608 2015-04-14 11:51 01_SerialPort\01_SerialPort\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 180 2015-03-18 08:57 01_SerialPort\01_SerialPort\obj\Debug\_01_SerialPort.Form1.resources
文件 180 2015-03-18 08:57 01_SerialPort\01_SerialPort\obj\Debug\_01_SerialPort.Properties.Resources.resources
文件 495 2015-03-18 08:57 01_SerialPort\01_SerialPort\Program.cs
文件 1358 2015-03-18 08:57 01_SerialPort\01_SerialPort\Properties\AssemblyInfo.cs
文件 2868 2015-03-18 08:57 01_SerialPort\01_SerialPort\Properties\Resources.Designer.cs
文件 5612 2015-03-18 08:57 01_SerialPort\01_SerialPort\Properties\Resources.resx
文件 1114 2015-03-18 08:57 01_SerialPort\01_SerialPort\Properties\Settings.Designer.cs
文件 249 2015-03-18 08:57 01_SerialPort\01_SerialPort\Properties\Settings.settings
文件 929 2015-03-18 08:57 01_SerialPort\01_SerialPort.sln
文件 17920 2015-03-18 08:57 01_SerialPort\01_SerialPort.suo
............此处省略42个文件信息
相关资源
- 串口调试助手代码(XCOM V2.0)
- WPF开发串口调试助手
- c#编写的串口调试助手
- 基于WPF MVVM框架开发的串口调试助手
- C# 串口调试助手源代码
- 串口调试助手C#源代码
- C#串口调试助手,收发数据保存在MY
- vs2010 c# 串口调试助手
- C#串口调试助手_VS2010()
- Wince6.0+C#串口调试助手源码
- C# 串口调试助手源码(自动搜索PC可用
- C#简单串口调试助手
- WinCE串口调试助手
- C#版串口调试工具源码vs2010免积分
- 自己用C#做的串口调试助手,完整源码
- 基于c#、wpf的串口调试助手
- Serialport 用VS2010编写的串口调试助手
- SerialPort 用C#编写的一个串口调试助手
- CSharp_serial 用C#编的串口调试助手
- COMTools_v2.0 C# 串口调试助手源代码。检
- SerialPortTerminal 基于C#的串口调试助手
- C# 串口调试助手+实时多种绘图方式
- 串口调试助手
- 串口调试助手
- c# 串口调试助手源码
- 赞C#串口调试助手WPF
- C#串口调试助手附加MATLAB画图
- C# 串口调试助手
- C#串口调试助手(源码)
- C# 串口调试助手
评论
共有 条评论