欢迎反馈建议,其中包含了串口类、XML类、数据库类等功能。程序中使用线程处理数据接收用以解决SerialPort类死锁问题。
2022-05-24 00:12:42 243KB c# 串口 源码
1
namespace 串口实例 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnSend_Click(object sender, EventArgs e) { //手动发送 SendMsg(); } private void SendMsg() { this.serialPort1.Write(this.txtSend.Text); } #region 控制输入数字 private void ComboBox_TextUpdate(object sender, EventArgs e) { ComboBox cbo = sender as ComboBox; int n; if (!int.TryParse(cbo.Text, out n)) { cbo.Text = cbo.Text.Substring(0, cbo.Text.Length - 1); } else { if (n <= 0) { cbo.Text = cbo.Text.Substring(0, cbo.Text.Length - 1); } } } private void txtTime_TextChanged(object sender, EventArgs e) { TextBox text = sender as TextBox; int n; if (!int.TryParse(text.Text, out n)) { text.Text = text.Text.Substring(0, text.Text.Length - 1); } else { if (n <= 0) { text.Text = text.Text.Substring(0, text.Text.Length - 1); } else { this.timer1.Interval = n; } } } #endregion /// /// 清空显示文本框 /// /// /// private void btnClear_Click(object sender, EventArgs e) { this.txtRecive.Clear(); } private void timer1_Tick(object sender, EventArgs e) { SendMsg(); } private void cbtSend_CheckedChanged(object sender, EventArgs e) { CheckBox check = sender as CheckBox; if (check.Checked) { this.timer1.Start(); } else { this.timer1.Stop(); } } /// /// 接收返回的数据 /// /// /// private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { string a=""; if (this.cbkShow16.Checked) { //十六进制显示 a = this.serialPort1.ReadExisting(); } else { //字符串显示 byte[] by = new byte[this.serialPort1.BytesToRead]; this.serialPort1.Read(by, 0, this.serialPort1.BytesToRead); a = Encoding.ASCII.GetString(by); } this.txtRecive.AppendText(a); this.txtRecive.ScrollToCaret(); } private void Form1_Load(object sender, EventArgs e) { //加载 this.serialPort1.RtsEnable = true; button1_Click(this.btnOpen, null); } private void button1_Click(object sender, EventArgs e) { Button btn = sender as Button; if (btn.Text == "打开端口") { try { this.serialPort1.PortName = this.cboPortName.Text; this.serialPort1.BaudRate = Convert.ToInt32(this.cboRaudRate.Text); this.serialPort1.DataBits = Convert.ToInt32(this.cboDataBits.Text); this.serialPort1.ReceivedBytesThreshold = Convert.ToInt32(this.cboReceivedBytesThreshold.Text); this.serialPort1.Open(); btn.Text = "关闭端口"; } catch { MessageBox.Show("打开端口失败,请检查端口是否被占用."); } } else { this.serialPort1.Close(); btn.Text = "打开端口"; } } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { try { this.serialPort1.Close(); } catch { } } } }
2022-05-17 15:17:21 52KB C# 串口 源码
1
深入浅出VC++串口编程之基于Win32 API 源码 参照该文档编写 同步阻塞方式 非常适合初学者 点击发送之后不要移动鼠标,否则会导致无响应,因为是同步方式 仅供学习,下一步我会上传异步通讯方式的,建议大家以后写串口软件都写异步的,这样效率高 vs2005编译通过
2022-03-31 11:33:00 12.83MB Win32 API 串口源码 VS2005
1
一个类似串口调试助手的小程序,C#写的,有全部C#源代码,串口调试助手最多找到4个串口,这个利用串口控件类的静态成员函数找到电脑上的串口(可能不止4个,包括虚拟串口),能实现字符方式的串口收发。
2022-03-29 23:10:57 45KB C# 串口号 串口控件
1
Labview 串口通讯源代码
2022-03-25 14:22:22 62KB labview 串口源码
1
1、可以使用vs2019/vs2017 Qt进行编译 2、源码说明链接:https://mingshiqiang.blog.csdn.net/article/details/80733737
2022-02-22 19:06:11 12KB qt stm32 开发语言 arm
vb.net 串口源码
2021-12-21 11:05:08 178KB vb.net串口源码
1
vb与施耐德PLC串口通讯,可读,写16位整数,32位浮点,32位整。
2021-12-19 19:41:09 208KB vb 施耐德 串口
1
linux下的Qt串口编程,运行在开发板上,包内有可执行程序chuankou,可以直接运行。可进行16进制发送数据。有软键盘操作。
2021-12-16 16:02:04 54KB linux软键盘 QT 串口 源码
1
添加绘图功能和虚拟串口工具 采用C++语言制作 界面友好 代码简单易懂 画图功能强大, 还有虚拟串口工具
2021-12-16 01:52:23 5.89MB 串口,源码,绘图,
1