资源简介
本资料是杜洋工作室所出版的上位机教程的讲义资料,包括课上所用到的各种历程。

代码片段和文件信息
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 串口控制
{
public partial class Form1 : Form
{
//device 1
const byte DeviceOpen1 = 0x01;
const byte DeviceClose1 = 0x81;
//device 2
const byte DeviceOpen2 = 0x02;
const byte DeviceClose2 = 0x82;
//device 3
const byte DeviceOpen3 = 0x03;
const byte DeviceClose3 = 0x83;
//SerialPort Write Buffer
bool Button1Statue;
byte[] SerialPortDataBuffer = new byte[1];
public Form1()
{
InitializeComponent(); //窗口构造
}
private void button1_Click(object sender EventArgs e)
{
if (serialPort1.IsOpen) //串口打开就关闭
{
try
{
serialPort1.Close();
}
catch { } //确保万无一失
//button1.Text = “打开串口“;
button1.BackgroundImage = Properties.Resources.Image2; //灭
Button1Statue = false; //按钮状态
}
else
{
try
{
serialPort1.PortName = comboBox1.Text; //端口号
serialPort1.Open(); //打开端口
//button1.Text = “关闭串口“;
button1.BackgroundImage = Properties.Resources.Image1;//亮
Button1Statue = true; //按钮状态
}
catch
{
MessageBox.Show(“串口打开失败““错误“);
}
}
}
private void Form1_Load(object sender EventArgs e)
{
SearchAndAddSerialToComboBox(serialPort1 comboBox1);
}
private void WriteByteToSerialPort(byte data) //单字节写入串口
{
byte[] Buffer = new byte [2]{0x00 data }; //定义数组
if (serialPort1.IsOpen) //传输数据的前提是端口已打开
{
try
{
serialPort1.Write(Buffer 0 2); //写数据
}
catch
{
MessageBox.Show(“串口数据发送出错,请检查.““错误“);//错误处理
}
}
}
private void SearchAndAddSerialToComboBox(SerialPort MyPortComboBox MyBox)
{ //将可用端口号添加到ComboBox
string[] MyString = new string[20]; //最多容纳20个,太多会影响调试效率
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 962 2013-07-16 00:16 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1.sln
..A..H. 43520 2013-07-31 11:42 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1.v11.suo
文件 1843 2013-12-05 09:47 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs
文件 5391 2013-07-17 00:45 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs
文件 6011 2013-07-17 00:47 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx
文件 505 2013-07-16 00:16 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs
文件 3761 2013-07-16 00:22 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\WindowsFormsApplication1.csproj
文件 3072 2013-12-05 11:39 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\WindowsFormsApplication1.suo
文件 1368 2013-07-16 00:16 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\Properties\AssemblyInfo.cs
文件 2900 2013-07-16 00:16 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.Designer.cs
文件 5612 2013-07-16 00:16 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.resx
文件 1111 2013-07-16 00:16 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.Designer.cs
文件 249 2013-07-16 00:16 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.settings
文件 6868 2013-07-16 00:22 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Release\DesignTimeResolveAssemblyReferencesInput.cache
文件 1415 2013-07-16 22:15 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6250 2013-12-05 13:33 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 2901 2013-12-05 13:33 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt
文件 975 2013-07-17 00:47 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache
文件 2143 2013-07-16 00:22 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache
文件 10240 2013-12-05 09:47 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe
文件 180 2013-12-05 09:46 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form1.resources
文件 34304 2013-12-05 09:47 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb
文件 180 2013-12-05 09:46 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources
文件 512 2013-12-05 09:46 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\GenerateResource.read.1.tlog
文件 1174 2013-12-05 09:46 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\GenerateResource.write.1.tlog
文件 22472 2013-07-16 00:22 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release\WindowsFormsApplication1.vshost.exe
文件 490 2009-08-31 00:40 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release\WindowsFormsApplication1.vshost.exe.manifest
文件 10240 2013-12-05 09:47 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
文件 34304 2013-12-05 09:47 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
文件 11592 2013-12-05 13:33 杜洋C#资料\第2、3集:C#软件项目\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
............此处省略555个文件信息
- 上一篇:c#+sql人事工资管理系统
- 下一篇:C#登录注册文档教程验证码.
相关资源
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
评论
共有 条评论