建议 - 从客户端到服务器的实时数据处理
我正在寻找有关如何实现以下目标的建议/指导:
我安装了一个电路并将其连接到 Arduino,并且我能够使用 Python 和 pySerial 模块轻松地从中检索数据。它使我能够确定模拟输入随时间变化的值。
目前,我正在将该数据存储到一个文件中,并带有时间戳和相应的值,我很想听到关于如何将这些数据“共享”到网络服务器并实时“播放”的意见和想法。
是否可以将值“流”到转储文件中并同时通过 AJAX 请求从中检索数据,或者我应该研究事件驱动的 Web 服务器,例如“Tornado”、“Twisted”
...这里有点迷失了。郑重声明一下,我对 PHP 和 JavaScript 的最终输出很满意,我只是不知道如何不断地“传输”我需要的数据。
提前致谢。
I am looking for advice/guidance on how to achieve the following:
I have a circuit mounted and connected to an Arduino and I am able to easily retrieve data from it, using Python and the pySerial module. It allows me to determine the value of an analog input over time.
At the moment I am storing that data to a file, with a time stamp and the correspondent value and I would love to hear opinions and thoughts on how I could 'share' this data to a web server and 'play' it live.
Is it possible to 'stream' the values into the dump file and retrieve data from it at the same time through an AJAX request or should I look into event-driven web servers like 'Tornado', 'Twisted'...
I am a bit lost here. Just for the record, I am comfortable with PHP and JavaScript for the final output, I just don't have a clue on how to constantly 'stream' the data I need.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不打算对 Arduino 设备进行太多更新,那么让 Python 组件继续通过串行端口收集数据并以一种可以轻松被可以分发数据的服务使用的方式发布它是有意义的。以更有效且可能更灵活的方式提供信息。
例如
假设您选择 1 或 2,则可以使用实时网络解决方案 将数据分发给任意数量的客户端。您可以在此处使用 Pusher,也可以使用自托管解决方案。
因此,我看到的数据流将是:
Ardunio ->小型 Python 应用程序 ->队列(或对 Web 服务器的 HTTP 请求)->实时网络技术 ->许多客户
If you don't plan to update the Ardunio device too much then it would make sense to have the Python component continue to collect the data over the serial port and publish it in a way that can easily be consumed by a service which can distribute the information in a more efficient, and probably flexible, manner.
e.g.
Assuming you go with 1 or 2, you can then use realtime web solution to distribute the data to any number of clients. You could use Pusher here or you could use a self hosted solution.
So, the data flow as I see it would be:
Ardunio -> small Python app -> Queue (or HTTP request to Web server) -> Realtime Web Technology -> Many clients