Modbus Serial sequence

Hi,

I'm newbie in node red.
For me it's an excellent tool with a high potential.

In a RPI3B+ I have made a sqlite DB write, dashboard and openweathermap get, and it's working ok, but I need to solve two problems that I don't know how to do it.

1- In the modbus Serial I need to sequence the polling. I've made a function to do this, but I think that work in boolean outputs it's not right.

Code function I've made:
var now= new Date();
var seg= now.getUTCSeconds();
var msg1,msg2,msg3,msg4;

if (0>seg<10) {msg1=true;}
else{msg1=false;}
if (10>seg<20) {msg2=true;}
else{msg2=false;}

return [msg1,msg2];

In debug window message me: "Function tried to send a message of type boolean"

How can I do this sequence work fine?

The variables I read in modbus, I want to save in a global to use this values in other flows. How can I do it?

Thanks in advance

You can't send a Boolean. The msg must be an object.

Just to amplify that a bit you probably want something like

else msg1 = {payload: false}

which creates a message with the payload set to false.

What Modbus library / node(s)? node-red-contrib-modbus?

Hi,

Thank you all.
I've solved this problem, a flow example helped me.

@thatcadguy, yes I'm using node-red-contrib-modbus