简体   繁体   English

读取ASP.NET C#中的客户端串行端口

[英]Read Client side Serial Port in ASP.NET C#

i need help in reading clients Serial port (COM port) from my web application. 我需要从我的Web应用程序读取客户端串行端口(COM端口)的帮助。 i am able to read it on windows application but if i wants to put it over the web. 我能够在Windows应用程序上阅读它,但是如果我想将其放在网络上。 is it possible to do so? 有可能这样做吗?

I could be wrong, but I don't think it's possible to read a serial port (or indeed any type of port) directly from the browser because there isn't going to be any interface to the underlying system hardware, etc. 我可能是错的,但是我认为不可能直接从浏览器读取串行端口(或者实际上是任何类型的端口),因为不会有与底层系统硬件的任何接口,等等。

However depending on what you need to do there are a couple of options (and probably more that I haven't thought of) 但是,根据您需要执行的操作,有几种选择(可能还有我没有想到的更多选择)

Browser plugin 浏览器插件

You could write a browser plugin that can do whatever it wants (within the limitations of a browser plugin of course) and can be used by your webpage by injecting the serial data feed into the page. 您可以编写一个浏览器插件,该插件可以执行任何操作(当然是在浏览器插件的限制之内),并且可以通过将串行数据馈送注入页面来供您的网页使用。

The problem with this would maybe having to create plugins for all browsers (assuming you want the web application to run on whatever browser the user chose) 这个问题可能需要为所有浏览器创建插件(假设您希望Web应用程序在用户选择的任何浏览器上运行)

Self-hosted WebAPI in a desktop app 桌面应用程序中的自托管WebAPI

You could embed a self-hosted Web API into either your existing desktop app or a tray application / Windows service, etc, that interfaced with the serial port as you currently do. 您可以将自托管的Web API嵌入到现有的桌面应用程序或任务栏应用程序/ Windows服务等中,它们可以像当前一样与串行端口连接。

This app or service would read the data and "publish" it via a simple JSON-based api that your web app can GET (or could use web sockets to push the data once the initial connection is made by the web app) and could also accept commands from the web browser via POST , etc. 此应用程序或服务将读取数据并通过基于JSON的简单api“发布”您的Web应用程序可以GET (或在Web应用程序建立初始连接后即可使用Web套接字推送数据),并且还可以通过POST等从Web浏览器接受命令。

Your web application could then access this via HTTP to get the data and do whatever it liked with it. 然后,您的Web应用程序可以通过HTTP访问此数据以获取数据并对其进行任何处理。

Either way, I think the user is going to have to install something to their local system for this to work. 无论哪种方式,我都认为用户将必须在本地系统中安装一些软件才能正常工作。

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

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