Hello function 3 malfunction How it works

Hello, thank you very much for your help. I really like the joy of learning.

in function block
The part about the code doesn't seem to work well, but I also referenced information on the Internet.

var msg0={payload:(msg.payload[0]<<16+msg.payload[1])}
return msg0;

We will send you the node below.

buffer 1 value and
Buffer 2 values ​​are different. however
The calculated value continues to be 524288... I would like to know if there is a problem with the code or if it needs to be returned again.

thank you.
To everyone who replies and watches...
flows.json (1.9 KB)

You cannot compare values in Buffer1 with values in Buffer2 because they are in two seperate messages.
A function node can only work on a single message.
You need to combine them into one message by setting msg.topic "buffer1" or "buffer2" and use a Join node in manual mode.

I did it again separately and the result was the same.
Did I do something wrong?

We will send you a sample node below.
flows (1).json (2.8 KB)

Yes - you need to make the buffers appear a single message.

See this article in the cookbook for an example of how to join messages into one object.

thank you

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.