资源简介
C#调用MOXA公司的PComm.dll类库PComm(线程安全)
接口函数:
1、public int InitComm(Hashtable Ht_CommParam)
2、 public int SendFrame(string Str_SendFrame, ref string Str_RecFrame, int i_NewBaudrate = 0)
3、public int CloseComm()
4、public string GetCommErrMsg(int i_ErrCode)

代码片段和文件信息
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.Collections;
namespace PCommApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnSend_Click(object sender EventArgs e)
{
btnSend.Enabled = false;
try
{
Hashtable Ht = new Hashtable();
Ht.Add(“Port“ txbPort.Text.ToString());
Ht.Add(“Baud_Rate“ “9600“);
Ht.Add(“Parity“ “None“);
Ht.Add(“Byte_Size“ “8“);
Ht.Add(“Stop_Bits“ “1“);
Ht.Add(“Before_Delay“ “0“);
Ht.Add(“Byte_Delay“ “50“);
Ht.Add(“Read_Interval_Timeout“ “50“);
Ht.Add(“After_Delay“ “3000“);
string Str_Sendframe = txbSendframe.Text.Trim();
string Str_Recframe = string.Empty;
PComm SP = new PComm();
//初始化串口
int i_RtnCode = SP.InitComm(Ht);
if (i_RtnCode != 0)
{
MessageBox.Show(SP.GetCommErrMsg(i_RtnCode));
return;
}
try
{
//发送数据
ShowDebugMsg(“发送: “ + Str_Sendframe true);
i_RtnCode = SP.Sendframe(Str_Sendframe ref Str_Recframe 0);
if (i_RtnCode != 0)
{
ShowDebugMsg(SP.GetCommErrMsg(i_RtnCode) false);
return;
}
ShowDebugMsg(“接收: “ + Str_Recframe true);
}
finally
{
//关闭串口
SP.CloseComm();
}
}
finally
{
btnSend.Enabled = true;
}
}
///
/// 显示调试消息
///
///
/// ame“>
private void ShowDebugMsg(string Str_ShowMsgBoolean B_Isframe)
{
if (B_Isframe)
{
Str_ShowMsg = DateTime.Now.ToString()+ “ “ + Str_ShowMsg;
}
txtDebug.AppendText(Str_ShowMsg+“\r\n“);
txtDebug.ScrollToCaret();
txtDebug.Refresh();
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 82520 2010-08-17 18:30 PCommClass\PCommApp\PCommApp\bin\Debug\PCOMM.DLL
文件 16384 2017-02-28 11:36 PCommClass\PCommApp\PCommApp\bin\Debug\PCommApp.exe
文件 32256 2017-02-28 11:36 PCommClass\PCommApp\PCommApp\bin\Debug\PCommApp.pdb
文件 11600 2017-02-28 13:25 PCommClass\PCommApp\PCommApp\bin\Debug\PCommApp.vshost.exe
文件 490 2014-09-19 01:53 PCommClass\PCommApp\PCommApp\bin\Debug\PCommApp.vshost.exe.manifest
文件 2724 2017-02-28 11:36 PCommClass\PCommApp\PCommApp\Form1.cs
文件 3975 2017-02-28 10:36 PCommClass\PCommApp\PCommApp\Form1.Designer.cs
文件 5817 2017-02-28 10:36 PCommClass\PCommApp\PCommApp\Form1.resx
文件 5359 2017-02-27 15:28 PCommClass\PCommApp\PCommApp\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6262 2017-02-28 11:36 PCommClass\PCommApp\PCommApp\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 722 2017-02-28 13:25 PCommClass\PCommApp\PCommApp\obj\x86\Debug\PCommApp.csproj.FileListAbsolute.txt
文件 975 2017-02-28 10:39 PCommClass\PCommApp\PCommApp\obj\x86\Debug\PCommApp.csproj.GenerateResource.Cache
文件 9040 2017-02-27 16:27 PCommClass\PCommApp\PCommApp\obj\x86\Debug\PCommApp.csprojResolveAssemblyReference.cache
文件 16384 2017-02-28 11:36 PCommClass\PCommApp\PCommApp\obj\x86\Debug\PCommApp.exe
文件 180 2017-02-28 10:39 PCommClass\PCommApp\PCommApp\obj\x86\Debug\PCommApp.Form1.resources
文件 32256 2017-02-28 11:36 PCommClass\PCommApp\PCommApp\obj\x86\Debug\PCommApp.pdb
文件 180 2017-02-28 10:21 PCommClass\PCommApp\PCommApp\obj\x86\Debug\PCommApp.Properties.Resources.resources
文件 15438 2017-02-28 11:32 PCommClass\PCommApp\PCommApp\PComm.cs
文件 3711 2017-02-28 10:16 PCommClass\PCommApp\PCommApp\PCommApp.csproj
文件 489 2017-02-27 15:14 PCommClass\PCommApp\PCommApp\Program.cs
文件 1352 2017-02-27 15:14 PCommClass\PCommApp\PCommApp\Properties\AssemblyInfo.cs
文件 2868 2017-02-27 15:14 PCommClass\PCommApp\PCommApp\Properties\Resources.Designer.cs
文件 5612 2017-02-27 15:14 PCommClass\PCommApp\PCommApp\Properties\Resources.resx
文件 1095 2017-02-27 15:14 PCommClass\PCommApp\PCommApp\Properties\Settings.Designer.cs
文件 249 2017-02-27 15:14 PCommClass\PCommApp\PCommApp\Properties\Settings.settings
文件 866 2017-02-27 15:14 PCommClass\PCommApp\PCommApp.sln
..A..H. 20992 2017-02-28 13:27 PCommClass\PCommApp\PCommApp.suo
目录 0 2017-02-27 15:14 PCommClass\PCommApp\PCommApp\obj\x86\Debug\TempPE
目录 0 2017-02-28 11:36 PCommClass\PCommApp\PCommApp\obj\x86\Debug
目录 0 2017-02-27 16:29 PCommClass\PCommApp\PCommApp\bin\Debug
............此处省略10个文件信息
- 上一篇:C#AE最短路径网络分析
- 下一篇:asp.net多线程日志记录源码
相关资源
- 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#左侧导航菜单(动态生成)
- C#TCP 通信(TCP发送16进制)
- C# sql实现批量导入数据到数据库
- 生命游戏C#
评论
共有 条评论