Closed davidoc85 closed 7 years ago
You need to look at reading different data types from buffers: https://nodejs.org/dist/latest-v6.x/docs/api/buffer.html
The modbus node should not make any attempt to decode the values it gets back from the device, you need to do it in a function node down stream.
There was some discussion today at lunch about making a generic node that can unpack buffers into objects, but this is not something likely to be implemented soon
Would this help?
https://flows.nodered.org/node/node-red-contrib-protocolbuffersnode
No, that is specific to Google's Proto buffer packing format
Please can you point me in the right direction with an example like how to convert a 0003 buffer value to a number so it can be plotted? How about a raw float value to a number?
I will get more informed meanwhile.
It will depend if it's Little Endian or Big Endian. But something like this in a function node:
var float = msg.payload.readFloatLE() msg.payload = float return msg;
If that doesn't give a sensible number try swapping LE for BE at the end of readFloat
I was reading integer values good so far, however when trying to read float points, the message is encoded differently.
Example reading Temperature value using 2 registers and Float-BigEndian is giving me the following result:
17/11/2016, 15:14:09Indexlvl/1 : msg.payload : buffer [4]bf99999a
So it is reading bf99999a. Can we add modbus the ability to support float points?See nodes example below:
modbusfloat.txt