¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Parsing a string


 

¿ªÔÆÌåÓý

Hi Alan,

?

Mick¡¯s single function node is fine for processing Mike¡¯s string input. With the DLI the input is a base 10 number which equates to the binary position of the eight outlets.

A combo of both flows would be good for Miles use as it would give him visual indication and ability to control the relays.

?

Mike, if you need a hand let me know but this should get you on the right track.

?

73

Dave wo2x

?

?

From: [email protected] <[email protected]> On Behalf Of Alan Blind, WA9WUD
Sent: Friday, January 29, 2021 3:58 PM
To: [email protected]
Subject: Re: [nodered-hamradio] Parsing a string

?

Mike

I like the method Dave used in his DLI Relay Flow. ?The response is an eight-digit number, with 0 or 1 in each digit, depending on the relay status. ? Dave has a function to do a "logical and" for each digit to determine and outputs a true or false. ?Would this work for you? ? For example, if the second digit is 1, then the function "1 & 2" is true, because the binary of the second digit is 2**1 = 2 and 2 logical 2 is true. ?Likewise, for the third digit, 2**2 is 4 so the logical comparator is 4.

Alan. WA9WUD



And here is the function. ?Of course,var onmsg = { payload: msg.payload,topic:msg.topic };

var offmsg = { payload: msg.payload,topic:msg.topic };

=========================

?

var msg1 = { payload: msg.payload,topic:msg.topic };

var msg2 = { payload: msg.payload,topic:msg.topic };

var msg3 = { payload: msg.payload,topic:msg.topic };

var msg4 = { payload: msg.payload,topic:msg.topic };

var msg5 = { payload: msg.payload,topic:msg.topic };

var msg6 = { payload: msg.payload,topic:msg.topic };

var msg7 = { payload: msg.payload,topic:msg.topic };

var msg8 = { payload: msg.payload,topic:msg.topic };

?

?

//msg.payload=true;

onmsg.payload=true;

offmsg.payload=false;

?

if (msg.payload & ? 1) msg1.payload=true; else msg1.payload=false;

if (msg.payload & ? 2) msg2.payload=true; else msg2.payload=false;

if (msg.payload & ? 4) msg3.payload=true; else msg3.payload=false;

if (msg.payload & ? 8) msg4.payload=true; else msg4.payload=false;

if (msg.payload & ?16) msg5.payload=true; else msg5.payload=false;

if (msg.payload & ?32) msg6.payload=true; else msg6.payload=false;

if (msg.payload & ?64) msg7.payload=true; else msg7.payload=false;

if (msg.payload & 128) msg8.payload=true; else msg8.payload=false;

?

?

?

return [msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8];?you can download everything form the files section.

Join [email protected] to automatically receive all group messages.