【zt】ASP读取串口数据

2012-05-24 09:13:17  阅读 4407 次 评论 0 条

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> ASP读取串口数据 </title>

<meta name="generator" content="editplus" />

<meta name="author" content="" />

<meta name="keywords" content="" />

<meta name="description" content="" />

<script language="VBscript">

'//页面载入时自动打开串口进行监听

'Sub Window_OnLoad() 

'    MSComm1.PortOpen = True 

'End Sub

'//打开串口进行监听

Sub OpenPort() 

   if Not MSComm1.PortOpen Then   

   MSComm1.PortOpen = True 

   MsgBox "Port opened !", vbOKOnly, "Warning" 

   Else 

   MsgBox "Port already opened !", vbOKOnly, "Warning" 

   End if 

End Sub

'//关闭串口

Sub ClosePort() 

   if MSComm1.PortOpen Then   

   MSComm1.PortOpen = False 

   MsgBox "Port closed !", vbOKOnly, "Warning" 

   Else 

   MsgBox "Port already closed !", vbOKOnly, "Warning" 

   End if 

End Sub

</script> 

<script ID="clientEventHandlersJS" language="javascript"> 

<!--

//串口事件驱动部分

function MSComm1_OnComm(){

   var fldWeight = frmView.txtWeight

   var strInput

   strInput = MSComm1.Input;

   window.alert(strInput);

   fldWeight.value == strInput;

   fldWeight.focus();

   return false;

//--> 

</script> 

<script language="javascript" FOR="MSComm1" EVENT="OnComm"> 

<!--

//串口事件驱动关联

MSComm1_OnComm()

//--> 

</script>

</head>

<body>

<object classid="clsid:648A5600-2C6E-101B-82B6-000000000014" id="MSComm1" codebase="MSCOMM32.OCX" type="application/x-oleobject"     style="left:54px;top:14px">

<param name="_ExtentX" value="1005"> 

<param name="_ExtentY" value="1005"> 

<param name="_Version" value="393216"> 

<param name="CommPort" value="1"> 

<param name="DTREnable" value="-1"> 

<param name="Handshaking" value="0"> 

<param name="InBufferSize" value="1024"> 

<param name="InputLen" value="0"> 

<param name="NullDiscard" value="0"> 

<param name="OutBufferSize" value="512"> 

<param name="ParityReplace" value="63"> 

<param name="RThreshold" value="14"> 

<param name="RTSEnable" value="0"> 

<param name="BaudRate" value="9600"> 

<param name="ParitySetting" value="0"> 

<param name="DataBits" value="7"> 

<param name="StopBits" value="0"> 

<param name="SThreshold" value="0"> 

<param name="EOFEnable" value="-1"> 

<param name="InputMode" value="0"></object> 

<form action="" method="post" id="frmView" name="frmView"> 

<p> 

<input id="txtWeight" name="txtWeight" style="left:50px;top:17px"></p> 

<p>   </p> 

<p> 

<button OnClick="OpenPort()" value="Open Port">Open COM Port</button> 

<button onclick="ClosePort()" value="Close Port">Close COM Port</button> 

</p> 

<p> 

</p> 

</form>  

</body>

</html>

 

此文从网络整理而来,作者不详。
 

本文地址:http://financialos.cn/?id=33
免责声明:本文为原创文章,版权归 jinesc 所有,欢迎分享本文,转载请保留出处!

发表评论


表情

还没有留言,还不快点抢沙发?