网页如何从用户的串口读取 - 2017年? [英] How can a web page read from the user's serial port - in the year 2017?

查看:18
本文介绍了网页如何从用户的串口读取 - 2017年?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从头开始重新实现现有系统.

I have to re-implement an existing system from scratch.

在某一时刻,当用户导航到某个网页时,服务器必须从用户的串行端口读取数据.

At one point, when the user navigates to a certain web page the server must read data from the user's serial port.

目前网页有一个ActiveX控件;当页面加载时,ActiveX 控件调用用户 PC 上的 COM DLL,后者从串行端口读取数据.

Currently, the web page has an ActiveX control; when the page is loaded the ActiveX control calls into a COM DLL on the user's PC which reads data from the serial port.

该系统已有 10 年历史.有什么更好"的方法可以实现这一点吗?

The system is 10 years old. Is there any "better" way that I could implement this?

例如,技术在过去十年中不断发展.这个解决方案似乎只适用于 MS IE,它现在的市场份额约为 26%(在 2013 年,当我上次更新这个问题时.截至 2107 年 2 月,MS IE 有 3-4%,Edge 有1-2%.由于 Edge 也是 MS 产品,它可能支持 Active X - 我没有尝试过.Otoh,因为它是全新的,所以有这是一个很好的机会,它没有).

For instance, technology has move on in the last ten years. And this solution seems only to work in MS IE, which now has a market share of about 26% (it had, in 2013, when I last updated this question. As of Feb 2107, MS IE has 3-4% and Edge has 1-2%. As Edge is also a MS product, it might support Active X - I have not tried. Otoh, since it is new from the ground up, there is a good chance that it does not).

HTML 5 是否提供了任何新的可能性?Cordova 之类的产品怎么样?

Did HTML 5 offer any new possibilities? What about products like Cordova?

还有其他可能吗?

我可以添加一个 Raspberry Pi 来通过串口读取数据吗?并让浏览器应用程序通过 RESTful 服务与之通信?

Could I add a Raspberry Pi to do the reading over serial port & and have the browser app communicate with that over a RESTful service?

[更新] @ EuroMicelli 说我将假设您有充分的理由从 Web 浏览器而不是本机应用程序运行您的应用程序".我不知道,因为最初的项目计划时我不在身边(设计它的公司现已解散).

[Update] @ EuroMicelli said "I'm going to assume that you have a very good reason to run your app from a web browser, instead of a native app". I don't know as I wasn't around when the original project was planned (and the company which designed it is now defunct).

也许他们不希望最终用户直接与数据库交互?也许基于浏览器"在当时是一个新的流行词?我个人对桌面应用程序没有问题(因为我发现它们更容易实现),但也许我们应该考虑继续基于浏览器?(此外,我可以自己处理桌面应用程序;只有基于浏览器的 COM 端口读取才能让我提供奖励;-)

Perhaps they didn't want the end user interfacing directly with the database? Perhaps "browser based" was a new buzzword back then? I, personally, have no problem with a desktop app (as I find them easier to implement), but maybe we should consider remaining browser based? (besides, I can handle the desktop app myself; it's only browser based reading from the COM port that leads me to offer a bonus ;-)

推荐答案

只是为了命名另一个(更像是物联网")选项:外部硬件.

Just to name another (more like "web-of-things") option: external hardware.

根据用例,您可以使用外部低成本设备,如 arduino 微控制器或 raspberry-pi 嵌入式 PC.

Depending on the use-case you COULD use an external low cost device like an arduino microcontroller or raspberry-pi embedded pc.

在这些类型的设备上构建一个简单的串行到 Web 服务的桥并不难.你可以使用一些这样的项目,例如:https://code.google.com/p/serwebproxy/

It's not very difficult to build a simple serial to web-service bridge upon these kind of devices. You could use some projects like this e.g. : https://code.google.com/p/serwebproxy/

在这种情况下,所有低级的东西都由外部硬件处理,并由类似接口的网络服务提供给您(通过 get/post).

In such a scenario all the low level stuff is handled by the external hardware and is offered to you by a web-service like interface (via get/post).

另一个优点是运行应用程序的个人电脑不需要串行端口(这在某些系统上变得非常少见).

Further advantage is that the pc, where you application runs on, doesn't need a serial port (which becomes quite rare on some systems).

从您的浏览器应用程序中,您可以通过一个简单的 ajax 调用查询嵌入式设备上的网络服务.浏览器根本不需要任何插件,该解决方案跨平台工作并且是通用的,并且在不久的将来独立于浏览器技术的开发.

From your browser application you could query the web-service on the embedded device with a simple ajax call. The browser wouldn't need any plugin at all, the solution works cross plattform and is generic and independent from the development of browser-technologies in the near future.

这篇关于网页如何从用户的串口读取 - 2017年?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆