简体   繁体   English

Chrome 中的串口通信

[英]Serial Port communication in Chrome

I have a legacy application which is making use of ActiveX control for serial communication.我有一个使用ActiveX控件进行串行通信的遗留应用程序。 This is rightly communicating in IE.这是在 IE 中正确的通信。

Since ActiveX is IE specific technology obviously it will not run in Chrome or other browser由于 ActiveX 是 IE 特定的技术,它显然不会在 Chrome 或其他浏览器中运行

So I don't want to disturb the IE functionality and thought of introducing browser specific function as below.所以我不想打扰 IE 的功能,并考虑引入浏览器特定的功能如下。

$(document).ready(function(e){

 var isIEBrowserFlag = true;
 if(isIEBrowserFlag)
 {
  var obj = new ActiveXObject("MSCommLib.MSComm");
  obj.CommPort = commPort;
  obj.RThreshold = thresHold;
  obj.Settings = settings;
  obj.PortOpen = true;
  obj.DTREnable = true;
  obj.Output = "test";
 obj.PortOpen = false;

//other stuff
 }
 else
 {
    //chrome
 }
 //sendBagToPrinter(obj);
});

On googling I came to know about jQuery.parseXML() but how do I implement the same functionality as of IE in Chrome using $.parseXML()在谷歌搜索中,我开始了解jQuery.parseXML()但我如何使用 $.parseXML() 在 Chrome 中实现与 IE 相同的功能

Similar other plugins such as juart were tried, but not fitting my requirement.尝试了类似的其他插件,例如juart ,但不符合我的要求。

chrome.serial API provides access to client serial ports, but from a Chrome App. chrome.serial API 提供对客户端串行端口的访问,但来自 Chrome 应用程序。 My suggestion, for future support, use/write some kind of server for serial device and connect from browser to server via a json type communication.我的建议,为了将来的支持,为串行设备使用/编写某种服务器,并通过 json 类型的通信从浏览器连接到服务器。 See https://github.com/johnlauer/serial-port-json-serverhttps://github.com/johnlauer/serial-port-json-server

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM