资源简介
串口通信DLL,包括了串口数据发送,数据接收,数据接收等待...
该工程是一个实际应用于通信设备程序中的部分组件。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;
using System.IO;
using System.Windows.Forms;
namespace Com
{
public class ClsCom
{
public SerialPort Com;
//初始化
private void InitialCom()
{
//测试串口
getCom();
}
#region 串口设置
public void setCom(string[] ComStr)
{
File.WriteAllLines(Application.StartupPath + “\\com.glux“ ComStr);
}
public string [] getCom()
{
if (File.Exists(Application.StartupPath + “\\com.glux“))
{
string[] ComStr = File.ReadAllLines(Application.StartupPath + “\\com.glux“);
Com = new SerialPort(ComStr[0] Convert.ToInt32(ComStr[1]) Parity.None Convert.ToInt16(ComStr[2]) StopBits.One);
return ComStr;
}
else
{
Com = new SerialPort(“com1“ 19200 Parity.None 8 StopBits.One);
String[] ComStr = new string[5] { “com1“ “19200“ “8“ “无校验(NONE)“ “none“ };
File.WriteAllLines(Application.StartupPath + “\\com.glux“ ComStr); //创建该文件
return ComStr;
}
}
#endregion
#region 数据位调整
public void setDataBit(string ComStr)
{
string[] CC = new string[1] { ComStr };
File.WriteAllLines(Application.StartupPath + “\\Correction.glux“ CC);
}
public string getDataBit()
{
if (File.Exists(Application.StartupPath + “\\Correction.glux“))
{
string[] ComStr = File.ReadAllLines(Application.StartupPath + “\\Correction.glux“);
return ComStr[0];
}
else
{
String[] ComStr = new string[1] { “65536“ };
File.WriteAllLines(Application.StartupPath + “\\Correction.glux“ ComStr); //创建该文件s
return ComStr[0];
}
}
#endregion
#region 串口操作
//打开串口
public bool OpenCom()
{
InitialCom();
try
{
if (!Com.IsOpen)
{
Com.Open();
}
return true;
}
catch (Exception)
{
return false;
}
}
//关闭串口
public bool CloseCom()
{
try
{
if (Com.IsOpen)
{
Com.Close();
}
return true;
}
catch (Exception)
{
return false;
}
}
//获取串口返回的数据,有时间限制
public bool ReadGetComTime(byte data)
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 20480 2010-03-09 13:39 Com\Com\bin\Debug\Com.dll
文件 19968 2010-03-09 13:39 Com\Com\bin\Debug\Com.pdb
文件 7319 2010-03-09 13:39 Com\Com\ClsCom.cs
文件 1993 2010-01-26 14:11 Com\Com\Com.csproj
文件 118 2010-03-09 13:39 Com\Com\obj\Com.csproj.FileList.txt
文件 20480 2010-03-09 13:39 Com\Com\obj\Debug\Com.dll
文件 19968 2010-03-09 13:39 Com\Com\obj\Debug\Com.pdb
文件 1301 2010-01-18 11:53 Com\Com\Properties\AssemblyInfo.cs
文件 898 2010-01-18 11:53 Com\Com.sln
..A..H. 10240 2010-03-09 13:40 Com\Com.suo
目录 0 2010-01-18 11:53 Com\Com\obj\Debug\Refactor
目录 0 2010-01-18 11:53 Com\Com\obj\Debug\TempPE
目录 0 2010-03-09 13:39 Com\Com\bin\Debug
目录 0 2010-03-09 13:39 Com\Com\obj\Debug
目录 0 2010-01-18 11:53 Com\Com\bin
目录 0 2010-03-09 13:39 Com\Com\obj
目录 0 2010-01-18 11:53 Com\Com\Properties
目录 0 2010-03-09 13:39 Com\Com
目录 0 2010-01-18 11:53 Com
----------- --------- ---------- ----- ----
102765 19
- 上一篇:C#实现一维离散小波变换
- 下一篇:NModbu官方VB C# 全
相关资源
- 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#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
- c#向word文件插入图片
- C#左侧导航菜单(动态生成)
评论
共有 条评论