# Serial filter separates the outputs into different outputs

**URL:** <https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875>\
**Category:** General\
**Tags:** function-node\
**Created:** [18 September 2022 09:50 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875 "2022-09-18T09:50:37Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxino101578](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxino101578/32/64940_2.png) [@maxino101578](https://discourse.nodered.org/u/maxino101578)\
**Post date:** [18 September 2022 09:50 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/1 "2022-09-18T09:50:37Z")

</div>

I read the following Strings from an RS232 but I would like to have each String in a separate output does anyone have an idea how to do it?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/5/a59b8da948b6331bdf8db82a963c5ea3a7bb4779.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d192a6195f678ff95e43246216e2374a20052d1f.png)

Thanks so much

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [18 September 2022 11:45 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/2 "2022-09-18T11:45:48Z")

</div>

Hi @maxino101578

This will work,  
But someone may have a cleaner way.

Connect your serial output to the `join` node  
I have used 5 as the number of outputs on the function node and set 5 as the number of message parts on the `join` node based on your screenshot

We then split the batch into 5 outputs

```auto
[{"id":"31bdde550a6cf2b6","type":"function","z":"e7094296.ee2ea","name":"function 1","func":"const L0 = {payload:msg.payload[0]}\nconst L1 = {payload:msg.payload[1]}\nconst L2 = {payload:msg.payload[2]}\nconst L3 = {payload:msg.payload[3]}\nconst L4 = {payload:msg.payload[4]}\n\nreturn [L0,L2,L2,L3,L4]","outputs":5,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":680,"wires":[["71e1b5e52fd2e8d4"],[],[],[],[]]},{"id":"71e1b5e52fd2e8d4","type":"debug","z":"e7094296.ee2ea","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":860,"y":660,"wires":[]},{"id":"704ba4b9cab152cc","type":"join","z":"e7094296.ee2ea","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"5","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":430,"y":680,"wires":[["31bdde550a6cf2b6"]]}]

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/d/7dfed5e28b8f6252909d680329455243ea14ddb4.png)

---

<div class="post-metadata">

**Author:** ![maxino101578](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxino101578/32/64940_2.png) [@maxino101578](https://discourse.nodered.org/u/maxino101578)\
**Post date:** [18 September 2022 11:53 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/3 "2022-09-18T11:53:47Z")

</div>

> [@marcus-j-davies](#):
>
> This will work,  
> But someone may have a cleaner way.
> 
> Connect your serial output to the `join` node

Hi Marco, thank you very much for your reply, this is the result  
I try to always have the same result for the first issue

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/0/a0a20a8484168cdfe3a8dfdb9c2a754b7bfda355.png)

---

<div class="post-metadata">

**Author:** ![maxino101578](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxino101578/32/64940_2.png) [@maxino101578](https://discourse.nodered.org/u/maxino101578)\
**Post date:** [18 September 2022 16:08 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/4 "2022-09-18T16:08:56Z")

</div>

I would like to have a separate output for each single value, any ideas?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7fe2192e6dceef181477cb52239e788f7cdf9319.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [18 September 2022 16:12 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/5 "2022-09-18T16:12:33Z")

</div>

try the OUT -\> split node, to slice it up into separate values, instead of `\n` try `\t` as it appears to be a tab separated string.

---

<div class="post-metadata">

**Author:** ![maxino101578](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxino101578/32/64940_2.png) [@maxino101578](https://discourse.nodered.org/u/maxino101578)\
**Post date:** [19 September 2022 05:42 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/6 "2022-09-19T05:42:03Z")

</div>

Thanks a lot bakman2, I tried but the result is the same

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/4/e4f685de4f05481337bb69499d270dbeb699951d.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/9/e9cdc8a4fad462d6d159e976ea74c3d7da78e227.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [19 September 2022 06:06 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/7 "2022-09-19T06:06:05Z")

</div>

can you copy the output of one of those strings (using the copy icon in the debug window) and paste it here between 3 backticks ? (or use the `</>` icon in the editor here).

````auto
``` output ```

````

---

<div class="post-metadata">

**Author:** ![maxino101578](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxino101578/32/64940_2.png) [@maxino101578](https://discourse.nodered.org/u/maxino101578)\
**Post date:** [19 September 2022 06:51 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/8 "2022-09-19T06:51:31Z")

</div>

Copying with debug icon, the result is this:

payload

This is what's in the window:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/466757a490a4924f440b15657f7f976c78480214.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 September 2022 12:54 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/9 "2022-09-19T12:54:56Z")

</div>

I think @bakman2 meant Copy Valuet as described in this, which is one of our canned replies:

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

That should give you basically the same info as in the screenshot, but in a less ambiguous form.

---

<div class="post-metadata">

**Author:** ![maxino101578](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxino101578/32/64940_2.png) [@maxino101578](https://discourse.nodered.org/u/maxino101578)\
**Post date:** [19 September 2022 15:36 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/10 "2022-09-19T15:36:14Z")

</div>

Thanks a lot Colin I used the steps you say, but my data that I want to split is on the same line but I want to separate it.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/c/3c0f1c4a060188a12dd2afe0386c5850ee05acbc.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/2/9212a2ed7b4b222c8e3e38b4b0e00cd3c4277143.png)

---

<div class="post-metadata">

**Author:** ![maxino101578](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxino101578/32/64940_2.png) [@maxino101578](https://discourse.nodered.org/u/maxino101578)\
**Post date:** [19 September 2022 15:39 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/11 "2022-09-19T15:39:29Z")

</div>

One value, one output

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [19 September 2022 19:34 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/12 "2022-09-19T19:34:02Z")

</div>

> Thanks a lot Colin I used the steps you say, but my data that I want to split is on the same line but I want to separate it.

Yes we are aware, but if you paste the output here _in text_, we can possibly help you, screenshots don't work.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [19 September 2022 19:52 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/13 "2022-09-19T19:52:13Z")

</div>

You could use a function node after the the buffer array with something like:

```auto
const data = msg.payload // assuming this is the input array

data.forEach(e=>{
    let tmp = e.replace(/\s\s+/g, ' ').split(' ').pop()
    node.send({payload:parseFloat(tmp)})
})

return null

```

---

<div class="post-metadata">

**Author:** ![maxino101578](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxino101578/32/64940_2.png) [@maxino101578](https://discourse.nodered.org/u/maxino101578)\
**Post date:** [20 September 2022 16:55 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/14 "2022-09-20T16:55:49Z")

</div>

Sorry bakman2 below the result:  
[" 35.0 37.0 27 28 33\r\n","\r\n","SOC: 80.608A/h LEM: - 17.412A Vmed: 3.550V Vtot: 53.239V\r\n","Vmin: 3.492V ==\> 9 Vmax: 3.589V ==\> 7\r\n","TMax: 25.3 TMin: 19.5 Tint: 33.0 TdMax: 28.0 TcMax: 37.0\r\n","Ricarica 61% + Equi\r\n"]

---

<div class="post-metadata">

**Author:** ![maxino101578](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxino101578/32/64940_2.png) [@maxino101578](https://discourse.nodered.org/u/maxino101578)\
**Post date:** [21 September 2022 12:56 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/15 "2022-09-21T12:56:08Z")

</div>

The solution from this info

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b9dbb16aacc06d6332715324205f0bd64d1cce6d.png)

---

<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:** [20 November 2022 12:56 UTC](https://discourse.nodered.org/t/serial-filter-separates-the-outputs-into-different-outputs/67875/16 "2022-11-20T12:56:55Z")

</div>

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