简体   繁体   English

我的Web应用程序如何与串行端口通信

[英]How can my web app communicate with serial port

I have a cloud web app using asp web api and angular. 我有一个使用ASP Web API和Angle的云Web应用程序。 Both hosted on azure. 两者都托管在天蓝色。 I need my angular app to be able to communicate to serial port (read/write). 我需要我的角度应用程序才能与串行端口通信(读/写)。 How can I do this? 我怎样才能做到这一点?

I've read that chrome apps can connect to usb/serial, but i'm still confused of how it works. 我已经读过chrome应用程序可以连接到usb / serial,但是我仍然对其工作方式感到困惑。 Should i rebuild my apps to chrome apps, or should i create a seperate apps or can i just write chrome apps that open my actual web and access the serial from my current app? 我应该将我的应用程序重建为chrome应用程序,还是应该创建一个单独的应用程序,还是可以编写可以打开实际网络并从当前应用程序访问序列的chrome应用程序?

You don't have to rewrite your app. 您不必重写您的应用程序。 Just create a chrome app and use webview for your actual cloud app. 只需创建一个chrome应用程序,然后将webview用于您的实际云应用程序即可。 Basicaly you have to write the serial port communication in the chrome app context and pass the data to your webview context in your chrome app which is actually the app loaded from your cload. 基本上,您必须在chrome应用程序上下文中编写串行端口通信,并将数据传递到chrome应用程序(实际上是从cload加载的应用程序)中的webview上下文中。

Other approach is to write your whole application in an offline chrome app and communicate with your cloud server trought ajax or websocket. 另一种方法是在离线chrome应用程序中编写整个应用程序,并与ajax或websocket的云服务器通信。

Another thing might help is nw.js. 另一件事可能会帮助nw.js。 With this you can create desktop like apps with web technology. 借助此工具,您可以使用网络技术创建桌面类应用程序。 Basicaly in your nw.js app you will use a node.js serial modul for serial communication. 基本上,在您的nw.js应用程序中,您将使用node.js串行模块进行串行通信。

Or combinate these methods. 或结合使用这些方法。

I suggest one of the chrome app way cuz I have good experience with its serial module. 我建议使用一种Chrome应用程序方式,因为我对其串行模块有很好的经验。

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

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