网络浏览器与硬件设备通信的方式是什么?

发布于 2024-07-07 23:15:23 字数 420 浏览 6 评论 0原文

我有一个通过 USB 连接到 PC 的数据采集硬件设备,我想发送一些信息和设置,获取一些数据,然后在客户端检索获取的数据并将其发送到服务器。 该计划是使用门户网站与连接到客户端 PC 的设备进行通信。 我打算编写一个 DLL 来与设备通信。 我的客户端环境是Windows,使用Internet Explorer作为浏览器。 服务器端是Windows或者Linux。 从 Web 浏览器客户端到客户端设备进行通信的最佳方式是什么?

澄清:第一个目标是允许客户端 PC 将采集设置发送到设备。 这些设置可以在客户端手动输入,也可以来自服务器。 第二个目标是将获取的数据获取到服务器的数据库。 我不需要在客户端显示获取的数据。

硬件设备有一个CPU,但内存非常有限。 与设备通信的协议尚未确定,但我可以像 USB 驱动器一样访问该设备。

I have a data acquisition hardware device attached to a PC via USB that I'd like to send some information and settings, acquire some data, and then retrieve the acquired data on the client and send it to the server. The plan is to use a web portal to communicate with the device attached to the client PC. I was planning on writing a DLL to talk to the device. My environment on the client is Windows using Internet Explorer as the browser. The server side is Windows or Linux. What is the best way to communicate from a web browser client to a client-side device?

Clarification: The first goal is to allow the client PC to send acquisition settings to the device. The settings may be manually entered at the client or may come from the server. The second goal is to get the acquired data to the server's database. I don't need to display the acquired data at the client.

The hardware device has a CPU but very limited memory. The protocol to communicate with the device is undetermined, but I may access the device like a USB drive.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

荒人说梦 2024-07-14 23:15:23

您可以使用 Java 小程序并通过串行端口与设备通信。

You could use a Java applet and communicate with the device via serial port.

北座城市 2024-07-14 23:15:23

编写一个 ActiveX 插件来收集数据,但我不确定它是否会授予您所需的权限。 如果您可以在其他浏览器上运行,您可以尝试编写一个 Netscape 插件。 除了对插件主机施加的限制之外,我不知道还有什么限制。

Write an ActiveX plugin to collect the data but I am not sure if it will grant you the required permissions. You can try to write a Netscape plugin alternatively if you can run on another browser. I don't know any restrictions other than imposed over the plugin host.

暗地喜欢 2024-07-14 23:15:23

我们有相同的需求,正在评估在侦听 127.0.0.1:8080 的客户端上运行代理的选项。 代理可以与设备通信,任何本地浏览器都可以通过在 js 中向 127.0.0.1:8080 发出请求,然后将结果转发到 Web 门户来与代理通信。 不知道它是否会起作用,因为任何安全软件都可能禁止浏览器向 127.0.0.1 发出请求并压缩整个事情。

We have the same need and are evaluating the option of running a proxy on the client that listens on 127.0.0.1:8080. The proxy can talk to the device and any local browser can talk to the proxy by making requests to 127.0.0.1:8080 in js and then forwarding the results to the web portal. No idea if it will work as any security software could disallow the browser from making requests to 127.0.0.1 and squash the entire thing.

心凉 2024-07-14 23:15:23

许多设备可以以击键的形式发送输入。 当焦点位于输入字段时,来自设备的数据将用文本填充该输入字段。

如果您的数据具有固定长度或可预测的模式,您甚至可以使用 ajax 或类似方法自动将数据提交到服务器。

这种方法已成功应用于条形码扫描仪。

Many devices can send input in the form of keystrokes. When the focus is on an input field, data from the device will fill it with text.

If your data has a fixed length or predictable pattern, you can even automatically submit the data to a server using ajax or similar method.

This approach has been successfully employed with a barcode scanner.

秋叶绚丽 2024-07-14 23:15:23

与设备通信的不是网络浏览器,而是网络服务器。 换句话说,编写一个小型 Web 应用程序,代替(或补充)从数据库读取数据,从设备读取数据,并以 HTML 形式呈现给用户。

实现相同目的的另一种方法是编写一个守护程序,从设备轮询并写入数据库,然后编写一个前端来显示存储的数据。 如果您想按时间呈现过去的讲座记录,此方案会更好。 第一种方法最好使用浏览器作为设备的简单界面。

It's not the web browser that is communicating with the device, it's the web server. In other words, write a small web application that instead of (or in addition to) reading data from a database, reads from the device, and present to the user as HTML.

A different way to achieve the same would be to write a daemon that polls from the device and writes to a database, then write a frontend to present the stored data. This scheme is better if you want to present a record of past lectures against time. The first method is better to use the browser as a simple interface to the device.

听不够的曲调 2024-07-14 23:15:23

您可以采用简单的方法,使用嵌入式 Web 服务器作为服务来收集数据并像通过浏览器访问普通网站一样访问数据。 但它需要客户端启动该服务。

您也可以将其用作门户的代理,在这种情况下,您不必处理多个域的安全限制。

You can take the easy way and use an embedded web server as a service to collect the data and access it like an ordinary web site from the browser. It requires the client to start the service though.

You can use it as a proxy to your portal also, in which case you don't have to deal with security restrictions of multiple domains.

小霸王臭丫头 2024-07-14 23:15:23

通常,此问题可以通过在客户端计算机上安装第三方软件/驱动程序来解决。 GEM 智能卡读卡器就采用这种方法。 然而,我们需要记住,采用这种方法会使设计偏离瘦客户端模型。 更好的方法是在客户端计算机上创建服务。

Normally this issue is addressed by having a third party software/driver installed on the client machine. GEM Smart card reader uses this approach. However, we need to remember that taking such an approach makes the design deviate from thin-client model. A better way to do would be create a service on the client machine.

两相知 2024-07-14 23:15:23

如果您使用 USB 接口连接硬件,我建议使用 USB CDC EEM旨在提供以太网其他 USB 模拟并完全用于此目的的类 - 在嵌入式设备上公开 Web 服务器,例如这个< /a>,有多种设计。
小补充一下,您还需要在 PC 端实现 CDC EEM 类驱动程序才能使其正常工作。

If you using USB interface to connect your hardware i would suggest using USB CDC EEM class that is designed to provide Ethernet other usb simulation and used exactly for this purpose - expose web server on embedded devices, this one for example, in various designs.
Small addition you will need to implement CDC EEM class driver on PC side as well to get this working.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文