Filtering data and outputting to Function node with multiple outputs

Hopefully somebody can help me with the following:
I have incoming serial data with needs to be separated via a function node, now i am able to split the sentence to their propiatary ID but i can´t manage to send them to their designated Function node output on the message nr. ID.
The sentence is as follows:

Where the number 8 is the total amount of messages and the number 1 till 8 are the message nr.
The number 8 can also excist lower than 8 but the given fact are the message numbers.
Now i am able to split on the talker ID $GPGDV, $GLGSV and $GSGSV so that´s sorted, the only thing i am struggling with is to send the sentences with their message nrs. to a function node output as sentence.
In this case $GPGSV does consist 4 separate message nrs. which needs to be send to their individual output on a function node.
As you can see i do get the 4 sentences (sentence 1 till 4) out on the function node but need to have them all separately. so the sentence with message ID nr. 1 to Function node output 1, sentence with message nr 2 to output 2, sentence with message nr. 3 to output 3 and message nr. 4 to output 4.

Your help with be highly appreciated to help me further into bringing this data into a bargraph.

The switch node is provided to route messages on multiple outputs according to a property of the data.

By default it looks at msg.payload but any property can be used, such as msg.payload.message_nr

To do it in the function after you split the payload you can do.

const output = []; 
const parts = msg.payload.split(",")
output[parts[2]-1]  = {
    payload: {
        message_nr: parts[2]
        //add other items here
return output;

P.S When posting code please post as text so others can copy it and do not need to retype it.

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

   code goes here 

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

Got it working by using a Switch node, thanks for the hint, was a little headache but at the end it all worked out for me. PS. sorry for not posting the code inbetween ´´´ was quite late and couldn´t find the right keys to add the code :wink: .

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