70
rated 0 times
[
76]
[
6]
/ answers: 1 / hits: 17826
/ 7 Years ago, thu, march 9, 2017, 12:00:00
I'am trying to convert a array of 4 bytes to a float value. Here is the thing:
I get an answer from my request via ModbusTCP, this looks something like this:
{ data: [ 16610, 40202 ], buffer: { type: Buffer, data: [ 64, 226, 157, 10 ] } }
This string is converted into a json-object, parsed and accessed with
var ModbusArray = JSON.parse(msg.payload);
var dataArray = ModbusArray.buffer.data;
(the msg.payload comes from node red)
Until here it works find. The Array represents a floating value. In this case it should be a value of around 7.0.
So, here is my Question: how can I get a float from this dataArray?
More From » javascript