I've successfull installed "node-red-contrib-modbus" and I've no problem with float conversion (4 bytes register type) on modbus register using this function:
//var data = [64, 226, 157, 10];
var data = msg.payload.buffer;
// Create a buffer
var buf = new ArrayBuffer(4);
// Create a data view of it
var view = new DataView(buf);
// set bytes
data.forEach(function (b, i) {
view.setUint8(i, b);
});
// Read the bits as a float; note that by doing this, we're implicitly
// converting it from a 32-bit float into JavaScript's native 64-bit double
var num = view.getFloat32(0);
// Done
//console.log(num);
msg.payload = num;
return msg;
How can convert "signed long long" (8 bytes)????
I've tried and search on google but the problem remain....