连续数据流从linux命令行进入python脚本 [英] Continuous data stream from linux command line into python script

查看:285
本文介绍了连续数据流从linux命令行进入python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获得从外围设备到树莓派,最后到我的计算机(mac)的连续数据流。

I need to get a continuous stream of data flowing from a peripheral device, to a raspberry pi, and lastly to my computer (mac).

到目前为止,数据可以连续(实时)从外设,到我的树莓派的命令行。注意,数据流没有精确的结束(假设它继续永久)。

So far, the data is can make its way continuously (in real time) from the peripheral, to the command line of my raspberry pi. Note that there is no exact "end" to the data stream (assume it continues forever).

我也有一个脚本,可以通过TCP连续发送数据从树莓pi到我的电脑。然而,我不能将这两个提到的部分连接在一起。

I also have a script which can send data continuously by TCP from the raspberry pi to my computer. HOWEVER, I can't connect these two mentioned parts together.

当数据进入raspberry pi命令行时,我需要以某种方式在运行时将其加入我的send_TCP.py文件,以便数据显示在我的计算机终端实时。我一直在尝试这个几个小时,没有运气。

As the data comes into the raspberry pi command line, I need to somehow get it into my send_TCP.py file while it is running, so that the data appears in my computer's terminal in REAL-TIME. I have been trying at this for hours and have had no luck.

我已经尝试使用管道,重定向等来使这个工作,但我不知道如何发送从树莓派的终端获取数据到TCP程序,以便一切顺利进行。

I have tried using pipes, redirecting, etc. to get this to work but I can't figure out how to send get the data from the raspberry pi's terminal into the TCP program while it is running, so that everything happens smoothly.

有一种方法,从python脚本,只是简单地读取命令行中的值到一个python程序,以便我们可以使用他们的数据?

Is there any way, from a python script, to just simply read the values from the command line into a python program so that we can use their data?

有一个os.read()函数或者我可以使用的东西?还是管道的方式做到这一点?在任何情况下,我不能弄清楚,真的可以使用一些帮助。请尽可能帮助,尽可能彻底。非常感谢提前,这是非常感谢!非常感谢!

Is there an os.read() function or something I could use? Or are pipes the way to do this? In any case, I can't figure it out and could really use some help. Please help if possible, as thoroughly as you can. Thanks very much in advance, it is greatly appreciated! Thanks!

推荐答案

管道和stdin是否可以工作?

Would pipes and stdin work?

一个类似的问题刚好在几分钟前问。

Here is a similar question just asked a couple minutes ago.

从linux命令行读取with Python

这篇关于连续数据流从linux命令行进入python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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