如何在嵌入式设备服务器上实现websocket?

发布于 2024-08-20 21:13:27 字数 408 浏览 10 评论 0原文

我正在与一家电子设备制造商合作,将基于 LAN 的控制系统嵌入到产品中。这个想法是通过网络浏览器提供系统配置/控制界面,这样客户就不需要安装软件。我们可以通过嵌入式模块发送和接收串行数据来与设备进行通信。由于该设备还可以通过前面板 UI 进行控制,因此以极低的延迟保持远程 Web 界面同步带来了挑战。看起来 websockets 或某种 Push 是我们处理从服务器到客户端的实时事件所需要的。

我正在使用 Lantronix Mathport AR 嵌入式设备服务器。该单元开箱即用,可提供任何自定义 HTML 和 java servlet/applet。如果我们需要更大的灵活性,我们可以选择安装轻量级 Linux 发行版。我不确定如何实现任何服务器端应用程序,因为该设备没有运行标准 Apache。我相信它正在使用 Boa。

谁能指导我如何做到这一点的正确方向?

I am working with an electronics appliance manufacturer to embed LAN based control systems into the products. The idea is to serve up a system configuration/control interface through a web browser so clients never need to install software. We can communicate with the appliance by sending and receiving serial data through the embedded module. Since the appliance can also be controlled from a front panel UI, it creates a challenge to keep a remote web interface in sync with very low latency. It seems like websockets or some sort of Push is what we need for handling real time events from the server to clients.

I am using a Lantronix Mathport AR embedded device server. Out of the box the unit will serve up any custom HTML and java servlets/applets. We have the option to install a lightweight Linux distro if we need more flexibility. I am not sure how to implement any server side apps since the device is not running standard Apache. I believe it is using Boa.

Can anyone guide me in the right direction of how to do this?

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

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

发布评论

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

评论(3

对风讲故事 2024-08-27 21:13:27

一些一般信息...WebSocket 协议(此处为草案规范) 是 TCP 之上的一个简单层。这意味着,如果您的平台已经有一个 TCP 服务器,那么实现 WebSocket 只需几个小时的时间。该协议指定了握手和发送数据帧的两种方式。

我强烈建议您首先阅读 39 页的规范。

Some general info...The WebSocket protocol (draft spec here) is a simple layer on top of TCP. What this means is that, if you already have a TCP server for your platform, implementing the WebSocket is just a matter of hours. The protocol specifies a handshake and two ways of sending data frames.

I strongly suggest you start by reading the 39 pages spec.

提笔书几行 2024-08-27 21:13:27

正如 Tihauan 已经提到的,首先要阅读规范,并且还要注意,尽管 websockets 现在比 1 年前更加稳定,但仍然有一些变化正在进行中。

对我来说,关键点是要求 websocket 数据完全是 UTF-8 文本,这非常适合基于 JSON 的消息定义。

我们的系统使用嵌入式 Linux 形式,因此我们添加并使用了以下库:

使用上述作为支持库,我们创建了一个内部轻量级“客户端/服务器”,允许我们的其他软件模块注册某些适用的 Websocket 消息,并根据需要进行响应。效果很好。

祝你好运并致以最诚挚的问候,

As Tihauan already mentioned, start by reading the spec, and also note that there are still some changes ongoing, although websockets is now more stable than it was 1 year ago.

Key point for me was the requirement that websocket data is entirely UTF-8 text, which lends itself nicely to JSON based message definitions.

Our system uses a form of embedded linux, so we then added and made use of the following libraries:

Using the above as support libraries, we created an internal lightweight "client/server" that allowed our other software modules to register for certain, applicable, websocket messages, and respond as needed. Worked great.

Good luck and best regards,

提笔落墨 2024-08-27 21:13:27

我有点晚了,但 Mozilla 发布了一个名为“编写 WebSocket 服务器”的指南,它实际上指导您编写 WebSocket 服务器。

您需要了解 HTTP 的工作原理并具有中等编程经验。根据语言支持,可能需要 TCP 套接字知识。本指南的范围是介绍编写 WebSocket 服务器所需的最少知识。

https://developer.mozilla.org/en-US/文档/Web/API/WebSockets_API/Writing_WebSocket_servers

I'm a bit late, but Mozilla posted a guide entitled "Writing WebSocket servers", which literally guides you through writing a websocket server.

You will need to already know how HTTP works and have medium programming experience. Depending on language support, knowledge of TCP sockets may be required. The scope of this guide is to present the minimum knowledge you need to write a WebSocket server.

https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers

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