I have this function receiving a stream of data from a script running an analog to digital converter.
var t=msg.payload;
if(t!=="")
{
k=t.split(':');
for (i = 0; i < k.length; i++)
{
k[i]=parseFloat(k[i]);
}
msg.topic="Analogues";
if(k[0]&&k[1]&&k[2]&&k[3]&&k[4]&&k[5]&&k[6]&&k[7]&&k[8])
{
msg.payload={"AP0":k[0],"AP1":k[1],"AP2":k[2],"AP3":k[3],"Ah":k[4],"InstP":k[5],"SOC4":k[6],"SOC3":k[7],"SOC5":k[8]};
return msg;
}
}
The function is working fine until any of the values in the stream of data is a 0.
Then, if any of the values is a 0(zero), the function doesn't output anything.
This is the payload:
"26.443:3.296:0.749:1.000:0.010:19.815:100.01:100.01:100.01"
Since can happen that a specific value is just a 0, how can I solve this inconvenience?
Any help will be appreciated.
Thanks