# Get the data from running linux app in real time

**URL:** https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206
**Category:** General
**Created:** [24 February 2020 16:09 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206 "2020-02-24T16:09:55Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![XiaoBin](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@XiaoBin](https://discourse.nodered.org/u/XiaoBin)
#### Post date: [24 February 2020 16:09 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206/1 "2020-02-24T16:09:55Z")

</div>

Hello all

I am going to get the data on node-red from running app.  
The source code I am running is as following.

while(1){  
status = bscXfer(&xfer);  
if(xfer.rxCnt \> 0 && status \> 0) {  
cout \<\< "Received " \<\< xfer.rxCnt \<\< " bytes:\n";

```
            for(int i = 0; i < xfer.rxCnt; i++)
            {
                cout << xfer.rxBuf[i];
            }

            cout << "\n";
            xfer.rxCnt = 0;
        }
    }

```

This app is working well, but I am going to receive xfer.rxBuf[i] data on node-read in real time while app is running.

I have studied exec node and daemon node for it, but I have not found the solution for it.  
Hopefully I want to implement using stdout.  
What's the best method for it?

Thank you

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [24 February 2020 16:13 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206/2 "2020-02-24T16:13:17Z")

</div>

Have you thought about rather than read/write to/from stdout with the app/node-red, to utilise MQTT and send data from your app to Node-RED over MQTT? You would then run each as separate processes, and can start/stop both without having to keep the other process in mind, nor forking.

If you're not familiar with MQTT, here's a good getting started manual to understand the concept behind it. [https://www.hivemq.com/mqtt-essentials/](https://www.hivemq.com/mqtt-essentials/)  
On top of that, there are good C++ libraries available for MQTT.

---

<div class="post-metadata">

### Author: ![XiaoBin](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@XiaoBin](https://discourse.nodered.org/u/XiaoBin)
#### Post date: [24 February 2020 16:17 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206/3 "2020-02-24T16:17:43Z")

</div>

Thank afelix.

This thread is running once per 20 ~ 50ms.  
I am wondering that MQTT can support thus timing.  
What is your thought for it?

Regards

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [24 February 2020 16:21 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206/4 "2020-02-24T16:21:27Z")

</div>

> [@XiaoBin](#):
>
> This thread is running once per 20 ~ 50ms.  
> I am wondering that MQTT can support thus timing.

Hi, MQTT can support that but it might be a problem for your hardware, which platform are you using?

---

<div class="post-metadata">

### Author: ![XiaoBin](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@XiaoBin](https://discourse.nodered.org/u/XiaoBin)
#### Post date: [24 February 2020 16:22 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206/5 "2020-02-24T16:22:51Z")

</div>

I am using Raspberry PI Zero W.

---

<div class="post-metadata">

### Author: ![XiaoBin](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@XiaoBin](https://discourse.nodered.org/u/XiaoBin)
#### Post date: [24 February 2020 16:40 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206/6 "2020-02-24T16:40:49Z")

</div>

Hello afelix and ghayne

Thank you for your comments.  
I think MQTT is good for me, but I am not familiar to it.  
What MQTT library for C do you recommendon my application?

Thank you again.

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [24 February 2020 17:26 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206/7 "2020-02-24T17:26:43Z")

</div>

> [@XiaoBin](#):
>
> What MQTT library for C do you recommendon my application?

Depending on where you run your application, either use one of the standard Paho MQTT libraries ([regular](https://www.eclipse.org/paho/clients/c/) / [embedded](https://www.eclipse.org/paho/clients/c/embedded/)), or when running on Arduino or ESP8266/ESP32 that deploy through the Arduino IDE, use Nick's [PubSubClient](https://pubsubclient.knolleary.net/).

> [@XiaoBin](#):
>
> I am using Raspberry PI Zero W.

I am really not sure if a Pi Zero will be able to manage this on "every 20 ~ 50ms", while also running other applications on it. That equals between 20 and 50 times a second. The Pi zero series is remarkably slower than other raspberry models, as is to be expected.

---

<div class="post-metadata">

### Author: ![XiaoBin](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@XiaoBin](https://discourse.nodered.org/u/XiaoBin)
#### Post date: [25 February 2020 07:50 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206/8 "2020-02-25T07:50:24Z")

</div>

Thank you afelix

I am considering to IPC(Inter Process Communication) for communication between app and node-red.  
I have found node-red-contrib-ipc node for it.  
But I have some troubles to create & open the fifo.  
Also I am not sure if I can use node-red-contrib-ipc node on my application.

Please let you check my new solution and give me your suggestion.

Thank you.

---

<div class="post-metadata">

### Author: ![XiaoBin](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@XiaoBin](https://discourse.nodered.org/u/XiaoBin)
#### Post date: [27 February 2020 15:12 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206/9 "2020-02-27T15:12:26Z")

</div>

I have used MQTT as ghayne said before, then I resolved it.  
Thank you ghayne and afelix.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [12 March 2020 15:12 UTC](https://discourse.nodered.org/t/get-the-data-from-running-linux-app-in-real-time/22206/10 "2020-03-12T15:12:26Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
