资源简介
自己写的串口通讯帮助类,实现应答机制,通讯中发送一条指令会等待应答,同步异步都有

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
private delegate byte[] Del(string data);
SerialPortHelper sph = new SerialPortHelper(“COM2“);
SerialPortHelper sph1 = new SerialPortHelper(“COM3“);
Del d;
public Form1()
{
InitializeComponent();
sph.RecDataEvent += Sph_RecDataEvent;
sph1.RecDataEvent += Sph1_RecDataEvent;
}
private void Sph1_RecDataEvent(object sender RecDataArgs e)
{
if (richTextBox2.InvokeRequired)
{
Action actionDelegate = () => richTextBox2.Text = Encoding.Default.GetString(e.Data);
richTextBox1.Invoke(actionDelegate);
}
}
private void Sph_RecDataEvent(object sender RecDataArgs e)
{
if (richTextBox1.InvokeRequired)
{
Action actionDelegate = () => { richTextBox1.Text = Encoding.Default.GetString(e.Data); };
richTextBox1.Invoke(actionDelegate);
}
}
private void button1_Click(object sender EventArgs e)
{
sph.Open();
sph1.Open();
}
private async void button2_Click(object sender EventArgs e)
{
try
{
byte[] r = await sph.SendWithAckAsyc(“QWEQWEQWEWQE“);
MessageBox.Show(Encoding.Default.GetString(r));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button3_Click(object sender EventArgs e)
{
sph1.Send(“ACK“);
}
private void label1_Click(object sender EventArgs e)
{
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-03-31 13:44 串口帮助类实现超时机制\
目录 0 2020-03-31 13:44 串口帮助类实现超时机制\.vs\
目录 0 2020-03-31 13:44 串口帮助类实现超时机制\.vs\WindowsFormsApplication3\
目录 0 2020-03-31 13:50 串口帮助类实现超时机制\.vs\WindowsFormsApplication3\v14\
文件 48640 2020-03-31 14:34 串口帮助类实现超时机制\.vs\WindowsFormsApplication3\v14\.suo
目录 0 2020-03-31 14:34 串口帮助类实现超时机制\WindowsFormsApplication3\
文件 189 2020-03-31 09:42 串口帮助类实现超时机制\WindowsFormsApplication3\App.config
文件 5808 2020-03-31 14:27 串口帮助类实现超时机制\WindowsFormsApplication3\Form1.Designer.cs
文件 2145 2020-03-31 14:27 串口帮助类实现超时机制\WindowsFormsApplication3\Form1.cs
文件 6016 2020-03-31 14:27 串口帮助类实现超时机制\WindowsFormsApplication3\Form1.resx
文件 536 2020-03-31 09:42 串口帮助类实现超时机制\WindowsFormsApplication3\Program.cs
目录 0 2020-03-31 13:44 串口帮助类实现超时机制\WindowsFormsApplication3\Properties\
文件 1356 2020-03-31 09:42 串口帮助类实现超时机制\WindowsFormsApplication3\Properties\AssemblyInfo.cs
文件 2861 2020-03-31 09:42 串口帮助类实现超时机制\WindowsFormsApplication3\Properties\Resources.Designer.cs
文件 5612 2020-03-31 09:42 串口帮助类实现超时机制\WindowsFormsApplication3\Properties\Resources.resx
文件 1111 2020-03-31 09:42 串口帮助类实现超时机制\WindowsFormsApplication3\Properties\Settings.Designer.cs
文件 249 2020-03-31 09:42 串口帮助类实现超时机制\WindowsFormsApplication3\Properties\Settings.settings
文件 12847 2020-03-31 14:34 串口帮助类实现超时机制\WindowsFormsApplication3\SerialPortHelper.cs
文件 3993 2020-03-31 10:18 串口帮助类实现超时机制\WindowsFormsApplication3\WindowsFormsApplication3.csproj
目录 0 2020-03-31 13:44 串口帮助类实现超时机制\WindowsFormsApplication3\bin\
目录 0 2020-03-31 13:44 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Debug\
文件 20480 2020-03-31 14:27 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Debug\WindowsFormsApplication3.exe
文件 189 2020-03-31 09:42 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Debug\WindowsFormsApplication3.exe.config
文件 42496 2020-03-31 14:27 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Debug\WindowsFormsApplication3.pdb
文件 22696 2020-03-31 14:30 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Debug\WindowsFormsApplication3.vshost.exe
文件 189 2020-03-31 09:42 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Debug\WindowsFormsApplication3.vshost.exe.config
文件 490 2016-07-16 19:44 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Debug\WindowsFormsApplication3.vshost.exe.manifest
目录 0 2020-03-31 13:44 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Release\
文件 13312 2020-03-31 13:02 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Release\WindowsFormsApplication3.exe
文件 189 2020-03-31 09:42 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Release\WindowsFormsApplication3.exe.config
文件 28160 2020-03-31 13:02 串口帮助类实现超时机制\WindowsFormsApplication3\bin\Release\WindowsFormsApplication3.pdb
............此处省略31个文件信息
- 上一篇:Arduino智能鱼缸
- 下一篇:接口需求文档模板.rar
相关资源
- delphi 串口通讯
- WPF USB 网络 串口 通信软件
- B/S 网上订餐系统
- 教室管理系统.rar
- 小鸡快跑游戏.
-
分别适用于.NET fr
amework 2.0和4.0的E - 汽车租赁系统............................
- 单片机与PC机串口通讯仿真
- 德卡D8读写器关于读写感应卡的一些代
- halcon 测量助手
- 图片存储到数据库保存二进制文件并
- 用Socket写的简易FTP服务器和客户端
- 企业销售管理信息系统(全套)
- 串口操作类(justinio)
- 基于Petri网的工作流(完整的原创源代
- 选择题自动考试系统
- 多线程实例:桌面智能弹球小游戏
- 土地信息管理系统
- ServiceStack V3.9 全部dll
- PDF pdfview.ocx 无水印
- 无需共享打印机实现远程打印功能小
- 真正的破解版PDFView4NET
- 网页调用ActiveX控件获取串口数据
- openMV串口通讯_(2).zip
- Luence的与盘古分词的使用软件
- Emgu.CV 打开视频与人脸检测
- 麦克纳姆轮程序.rar
- Unity3D 实战视频教程 保卫萝卜 2D 游戏
- net微信支付
- lucene.net+盘古分词多条件全文检索并匹
评论
共有 条评论