• 博客(0)
  • 资源 (1)

空空如也

精品 html web电子称重软件通用socket+SerialPort串口

<input id="txtWeight" type="text" bold;" /> [removed] var ws; chengzhong(); function chengzhong(){ ws = new WebSocket("ws://127.0.0.1:9000"); ws.onopen = function(evt) { console.log("Connection open ..."); ws.send("Hello WebSockets!"); }; var stra=""; ws.onmessage = function(evt) { var wStr=evt.data; //var newstr = wStr.substring(0,wStr.length-3); //删除字符串后三个字符 //var newstrw = newstr.slice(2, newstr.length); //删除字符串前两个字符 //var strxs = newstrw.substr(newstrw.length-1,1); var strweigh = wStr.substring(0,wStr.length-3); //删除字符串后三个字符 //alert(strweigh); var result = strweigh.replace(/(.{4})/,"$1."); document.getElementById("txtWeight").value = Number(result); console.log("Received Message: " + evt.data); //ws.close(); }; ws.onclose = function(evt) { document.getElementById("txtWeight").value="请重启称重软件"; setTimeout(chengzhong,3000); console.log("Connection closed."); }; }

2019-04-10

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除