c#串口发送数据
来源:互联网 发布:美利坚仓储淘宝王 下载 编辑:程序博客网 时间:2024/05/22 03:49
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;namespace 串口1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { for (int i = 0; i < 256;i++ ) { string a = i.ToString("x").ToUpper(); string b = "0X" + a; if (i<16) { b = "0X0" + a; } comboBox1.Items.Add(b); } comboBox1.Text = "0X00"; } private void button1_Click(object sender, EventArgs e) { string a = comboBox1.Text.Substring(2, 2); byte[] buffer = new byte[1];//只需要1bity buffer[0] = Convert.ToByte(a,16); try { serialPort1.Open(); serialPort1.Write(buffer,0,1); serialPort1.Close(); label2.BackColor = Color.Red; } catch (System.Exception ex) { if (serialPort1.IsOpen)//属性调用 { serialPort1.Close(); } MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK); } } }}
阅读全文
0 0
- c#串口发送数据
- C#串口发送接受数据
- C#如何验证数据发送到串口
- C#实现串口数据循环发送
- C#开启关闭串口,发送数据
- 在VSPM下用C#串口编程发送数据
- C# SerialPort串口通信发送接收,处理接收数据完整
- C# 串口编程二 应用--接受发送数据
- C# UDP、串口的数据接收与发送
- C#通讯编程入门--串口数据接收发送实例
- 串口发送数据类
- 串口发送数据类
- STM32 串口发送数据
- USART---串口发送数据
- USART---串口发送数据
- 串口发送数据
- C#串口通信-向串口发送数据,同步接收返回数据
- c# 串口 writeline 发送字符串
- 【百度联盟峰会】李彦宏详解AI时代思维方式,算法驱动的降维攻击
- linux代码查看工具Scientific Toolworks Understand
- 按姓名,按成绩排序
- 离散7
- Android基础——3:Activity完全解析
- c#串口发送数据
- Java中有关null的9件事
- 将jar包制作成docker镜像
- 一天一个Linux命令:touch
- JavaScript
- 使用Makefile编译Java文件
- Android基础——4:UI之View
- 总结android数据持久化技术(1)
- 函数