I just wanna read floating point data from modbus tcp. Therefore I wanna convert modbus tcp all formats to Javascript using node red function node. Currently I can read only 32 bit float - little endian byte swapped only. Method I will mention below. How to do the rest ?
following code I used for 32 bit float - little endian byte swapped and its working fine.
thanks for the reply @kuema. But still im tryna figuring out how to do the task using this. Can I directly import modbus data to this binary node and do the conversion?
Doing it in a function node is just fine. It was just another solution if you try to decode more complex structures.
Both solutions rely on the usage of Buffers, so you need to investigate which output data the Modbus nodes can provide. Use a debug node in "complete message" mode for that.
We used it to retrieve data from Siemens Sentron devices, but that's been a while ago. But AFAIR we used the raw buffer data for that.
So the byte order of individual values (in your case 2 byte floats) is the same with LE/BE+swap, and BE/LE+swap respectively.
So you could just use the standard buffer methods like readFloatLE(offset), but read the buffer in the swap case from the end, instead of the beginning by using the offset.
Don't know if that will work for other data types as well, I don't know your raw data.