使用串口控件sax.net
http://www.sax.net/framework/communications/
我已经用它成功地应用于串口数据采集.
http://www.sax.net/framework/communications/
我已经用它成功地应用于串口数据采集.
解决方案 »
- .NET应用程序安装问题
- 不显示删除回复显示所有回复显示星级回复显示得分回复 使用clickOne发布程序时,怎样才能把水晶报表文件rpt一起发布
- 【??】关于写文件的问题
- 关于一个继承的问题
- c#中listview问题
- 请问在类前用[Serializable]有什么用啊
- 用SqlParemeter提交参数出现错误
- 导入数据库问题。快来帮忙
- 运行adp.Fill(ds)死机
- A question about how to communication between two PCs
- 如何在asp.net DocDisplay.aspx.cs 里面调用 DocDisplay.aspx 里面的asp程序 求帮忙!
- 请问:C#用什么开发环境!用什么工具?能提供下载吗?谢谢!
不知道调用API函数有没有用!
使用串口控件sax.net
有没有注册版的!
有的话!给一个!
[email protected]
谢了!!
这就是那个接收的代码
private void axMSComm_OnComm(object sender, System.EventArgs e)
{
switch( this.axMSComm.CommEvent)
{
case (int)CommEvent.MSCommEvReceive:
{
if(this.axMSComm.InBufferCount>0)
Byte[] newByte = (Byte[])this.axMSComm.Input;
//这里就写的你的分析代码就可以了 AnalyseData();
}
break;
}
case (int)CommEvent.MSCommEvSend:
{
break;
} case (int)CommError.MSCommErBreak:
{
StrLastError = "接收到中断信号!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
} case (int)CommError.MSCommErCTSTO:
{
StrLastError = "Clear To Send 超时!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
} case (int)CommError.MSCommErDSRTO:
{
StrLastError = "Data Set Ready 线为低电平!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
} case (int)CommError.MSCommErFrame:
{
StrLastError = "帧错误!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
} case (int)CommError.MSCommErOverrun:
{
StrLastError = "端口超速!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
} case (int)CommError.MSCommErCDTO:
{
StrLastError = "载波检测超时!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
}
case (int)CommError.MSCommErRxOver:
{
this.ClearReceiveBuf();
StrLastError = "接受缓冲区溢出!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
} case (int)CommError.MSCommErRxParity:
{
StrLastError = "奇偶校验!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
} case (int)CommError.MSCommErTxFull:
{
this.ClearSendBuf();
StrLastError = "传输缓冲区已满!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
} case (int)CommError.MSCommErDCB:
{
StrLastError = "载波检测超时!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
}
default:
{
StrLastError = "硬件意外错误!";
TestErrorList.Add(StrLastError);
Console.WriteLine(StrLastError);
break;
}
}
}
}
public void SendData(Byte sendData)
{
try
{
Byte[] sendChar = new Byte[1];
sendChar[0] = sendData;
this.axMSComm.Output = sendChar;
Thread.Sleep(6);
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}
}
我用的是:http://www.codeproject.com/dotnet/DotNetComPorts.asp