Function to Convert 16 bit HEX value to float value

#1

Hi!!
I have a piece of code wriiten in c.
How to do this in Node red function:

Blockquote
poutbuf[1] = FD;
pOutbuf[2] = 6F;
{
short signal;
float fsignal;
signal = (short)(pOutbuf[1]<<8);
signal += (short)(pOutbuf[2]);
fsignal = ((float)signal / 10.0);
printf("\r\GET_Signal\t\n\n", fsignal);
}

0 Likes

#2

That will convert to javascript almost as-is. You will not need to change the meaning of each line, just change to javascript syntax. You won't need the short and float typecasts.
I don't think the first two lines are valid C though, but I imagine that is just a typo.

0 Likes