On the serial I always receive this string in the same format:
I should break it down according to the native format:
What could be the best way to do it?
Thank you so much for your help.
R.
On the serial I always receive this string in the same format:
I should break it down according to the native format:
What could be the best way to do it?
Thank you so much for your help.
R.
In a function node with substring should do the trick if the length is always the same.
thanks, do you have a small example to start working on?
This should give you a start.
Basically extract the posts from the string in a function node, use parseInt were necessary to convert strings to numbers (search JavaScript parseInt for help on converting hex string parts to numbers)
var data = msg.payload;
var pl ={};//make new empty object
//Now populate the object with values
pl.data = data;//keep copy of original data. Handy for debugging
pl.stnNo = parseInt(data.substr(1,2));
pl.cmd = data.substr(3,2);
//... And so on
// Set payload to our new object
msg.payload = pl;
return msg;//return it to next node
So put that ^ in a function node, fill out the rest of the pl
object properties, add a debug node & check it's all correctly split up.
@Steve-Mcl ,
thank you so much for your help, that's just what i needed.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.