Decoding the binary array with buffer parser

Hello, would need a bit help here to understand this thing.
I have a battery device, which sends it's data on tcp port, every second.
Protocol documentation says:

image

I managed to connect with TCP node to that port and get data (stream of Buffer payloads). But now I don't understand how to decode that data to correct values.

image

Data, which I receive from TCP node, looks like this:
image

For example Cells temperature I tried with buffer-parser node:

and the result is array:
image

What should I do to get out value like temperature from that?

The size of the data in your image is 4 bytes therefore it is a 32bit number.

So you set the data type to match (probably int32be/int32le or floatBe/floatLe depending on how it is packed), set the offset to the correct position and length to 1 to "get one 32bit value".

As the built in help states:

length The quantity of items to be returned. e.g. 6 bools or 12 floats or 34 int32s.

I copied one buffer with real data and that monent system own app showed temperature 8.12°c (or 8.06°c, it was changing).

I still can not understand, how I can not get correct value. I tried all types you mentioned.

image

[
    {
        "id": "15b0d39fdc1eff30",
        "type": "inject",
        "z": "2c55f2a82c964ec5",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[50,55,218,161,216,175,4,16,0,200,70,0,0,0,0,0,0,0,0,136,255,36,0,0,0,146,39,1,0,0,0,40,0,0,146,39,0,0,0,0,40,0,53,146,39,44,3,0,0,40,0,56,146,39,0,0,0,0,40,0,54]",
        "payloadType": "bin",
        "x": 770,
        "y": 820,
        "wires": [
            [
                "12465585669b7f18",
                "4f5fdfc58b75118d"
            ]
        ]
    },
    {
        "id": "12465585669b7f18",
        "type": "buffer-parser",
        "z": "2c55f2a82c964ec5",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "floatle",
                "name": "cellsTemp",
                "offset": 46,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "resultType": "value",
        "resultTypeType": "return",
        "multipleResult": true,
        "fanOutMultipleResult": false,
        "setTopic": true,
        "outputs": 1,
        "x": 950,
        "y": 820,
        "wires": [
            [
                "34fdb5fee2db7896"
            ]
        ]
    },
    {
        "id": "34fdb5fee2db7896",
        "type": "debug",
        "z": "2c55f2a82c964ec5",
        "name": "debug 236",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1130,
        "y": 820,
        "wires": []
    },
    {
        "id": "4f5fdfc58b75118d",
        "type": "debug",
        "z": "2c55f2a82c964ec5",
        "name": "debug 237",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 950,
        "y": 880,
        "wires": []
    }
]

There are many reasons why you may not be getting sane values:

  • the data has padding at the start (e.g. you data starts at byte 47 or 48)?
  • the data may NOT be an IEEE 754 32 bit float (some devices make up their own float format)
  • the data may simply be an INT32 and require you to divide by 100 or 1000
  • the data may actually be Fahrenheit or kelvin and your APP converts it to Celcius.
  • the whole data string might be byte-swapped

Do you have a manual - perhaps it explains how values are packed into the data stream?

All I can suggest is capture several buffers of data, put them into inject nodes (like you did), setup a buffer parser with multiple entries ALL pointed to the same start byte BUT with different "types" (e.g. item1: int32be, item2: int32le, item3: float32be, item4: float32le) - see if you can spot 8.06 or 806 or 8060000 etc). See if you can spot something close.

If that doesnt work, Try changing the byteswap parameter. Try changing the byte offset by 1. etc etc.

1 Like

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