JSP JS MSCOMM32.OCX 网页传递串口数据
1、在本地安装MSCOMMSetup原始.exe, 目的是为了在本地注册MSCOMM32.OCX控件。
2、注册好了之后
先做个测试JSP,代码如下:
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
var CalendarWebControl = new atCalendarControl();
function prints(){
alert(printport);
}
function init(){
//document.all.printport.CommPort = "3";
// var object1=document.getElementById("printport");
// object1.PortOpen = true;
document.all.printport.PortOpen=true;
}
function doPrint(printmsg){
document.all.printport.Output = printmsg;
}
function pageEnd(){
document.all.printport.PortOpen = false;
}
</script>
</head>
<body onload='init();' onunload='pageEnd();'>
<p><object id="printport" classid="clsid:648A5600-2C6E-101B-82B6-000000000014" codebase="MCSCOMM32.cab" >
<param name="CommPort" value="3">
<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="0">
<param name="RTSEnable" value="0">
<param name="BaudRate" value="9600">
<param name="ParitySetting" value="0">
<param name="DataBits" value="8">
<param name="StopBits" value="0">
<param name="SThreshold" value="0">
<param name="EOFEnable" value="0">
<param name="InputMode" value="0">
</object></p>
<p><input type="button" value="Print" name="B1" onclick=prints();'></p>
</body >
</html>
当JS弹框为3,那么说明控件加载成功,程序已经可以向端口发数据了
上一篇: tomcat+mysql使用utf-8
下一篇: C语言中的时间函数(Linux)