Multiple outputs

I'm trying to get the ModBus flexwriter to work, but I am getting unreliable results using multiple function nodes as input the Flexwriter node. Seems I cant trust in which order the different node sends to the flexwriter.

Instead I would like to write all inputs in on function node i.e. have multiple objects send from one function node.

I was trying to this example from the node-red documentation, but this does not work for me and I can't figure out where it is going wrong.

I get only the first line, the remain three messages disappear and there is no second output.

var msg1 = { payload:"first out of output 1" };
var msg2 = { payload:"second out of output 1" };
var msg3 = { payload:"third out of output 1" };
var msg4 = { payload:"only message from output 2" };
return [ [ msg1, msg2, msg3 ], msg4 ];

Thank you in advance

I don't have enough information from you to understand why that code wouldn't work (so long as your function node has 2 outputs, it will work).

If you want to explicitly guarantee order, use something like

node.send(msg1);
node.send(msg2);
node.send(msg3);

To ensure correct order.

The code you posted should work. Are you sure you have the brackets in the right places?
Can you create a flow consisting of an inject node, the function node, and two debug nodes on the outputs and check that shows the problem. If so then export that here so we can replicate it. When pasting the flow here use the </> button at the top of the forum edit window and paste it in.

Thanks a million.

@Steve, Works perfectly.
@Colin, Still not working for me. I was trying out the example to try get to what Steve just send me. Just to better understand how it works I will try again later to see if I can make the example work.

Either technique should do what you want, but I think it is always good to understand why something that should work does not.

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