网页下面如何开发读串口数据的系统~MSCOMM控件~急~~~~~~~
我们现在用asp.net2003开发一个网页,在上面显示一个读打进来电话号码的程序
我们现在只能用2003,我知道2005自带了MSCOMM这个工具...没办法啊
用的是MSCOMM控件,但现在有问题啊~~
代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
InitComPort(SMSComm);
}
}
private void InitComPort(MSCommLib.MSComm com)
{
try
{
// Set the com port to be 1
com.CommPort = 1;
// This port is already open, close it to reset it.
if (com.PortOpen) com.PortOpen = false;
// Trigger the OnComm event whenever data is received
com.RThreshold = 1;
com.SThreshold=0;
// Set the port to 9600 baud, no parity bit, 8 data bits, 1 stop bit (all standard)
com.Settings = "9600,n,8,1 ";
// Force the DTR line high, used sometimes to hang up modems
com.DTREnable = true;
// No handshaking is used
com.Handshaking = MSCommLib.HandshakeConstants.comNone;
// Don 't mess with byte arrays, only works with simple data (characters A-Z and numbers)
com.InputMode = MSCommLib.InputModeConstants.comInputModeText;
//com.InputMode = MSCommLib.InputModeConstants.comInputModeBinary;
// Use this line instead for byte array input, best for most communications
//com.InputMode = MSCommLib.InputModeConstants.comInputModeText;
// Read the entire waiting data when com.Input is used
com.InputLen = 0;
// Don 't discard nulls, 0x00 is a useful byte
com.NullDiscard = false;
// Attach the event handler
com.OnComm += new MSCommLib.DMSCommEvents_OnCommEventHandler(this.OnComm);
// Open the com port
com.PortOpen = true; <------ 这句会报错
//com.Output = "Serial Terminal Initialized ";
}
catch(Exception e)
{
Response.Write(e.Message);
if(SMSComm.PortOpen) SMSComm.PortOpen = false;
return;
}
}
报的错为:HRESULT 中的异常:0x800A1F45。
上网找了一个都是说端口打开了,没有关闭!!
但我用了关闭的代码啊!!
真不知道是什么原因,希望大家帮下忙
还有就是读不出来电话号码~~
我想问一下,还有其它别的控件可开发的不,在2003下面?
[解决办法]
沙发,帮你顶
------解决方案--------------------
mark