Question about Buffer Parser and Hex

Hi,
I have a question about the offset "20":

[
    {
        "id": "e4b93f8b54e1a48d",
        "type": "inject",
        "z": "4726af68.c62a98",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[83,77,65,0,0,4,2,160,0,0,0,1,2,76,0,16,96,105,1,116,113,89,181,228,253,252,197,7,0,1,4,0,0,0,0,0,0,1,8,0,0,0,0,7,222,18,158,0,0,2,4,0,0,0,0,6,0,2,8,0,0,0,0,14,189,76,249,72,0,3,4,0,0,0,0,0,0,3,8,0,0,0,0,0,20,52,42,96,0,4,4,0,0,0,35,5,0,4,8,0,0,0,0,17,140,207,124,232,0,9,4,0,0,0,0,0,0,9,8,0,0,0,0,15,100,84,133,88,0,10,4,0,0,0,35,5,0,10,8,0,0,0,0,17,176,1,23,8,0,13,4,0,0,0,0,1,0,14,4,0,0,0,195,60,0,21,4,0,0,0,0,0,0,21,8,0,0,0,0,4,92,177,116,16,0,22,4,0,0,0,8,253,0,22,8,0,0,0,0,11,4,215,209,176,0,23,4,0,0,0,0,0,0,23,8,0,0,0,0,0,34,111,198,152,0,24,4,0,0,0,15,106,0,24,8,0,0,0,0,6,156,34,38,96,0,29,4,0,0,0,0,0,0,29,8,0,0,0,0,6,123,31,53,72,0,30,4,0,0,0,17,216,0,30,8,0,0,0,0,12,12,105,6,0,0,31,4,0,0,0,9,171,0,32,4,0,0,3,145,237,0,33,4,0,0,0,1,248,0,41,4,0,0,0,0,0,0,41,8,0,0,0,0,3,131,70,119,232,0,42,4,0,0,0,18,16,0,42,8,0,0,0,0,2,218,28,212,80,0,43,4,0,0,0,0,0,0,43,8,0,0,0,0,0,11,240,74,200,0,44,4,0,0,0,5,209,0,44,8,0,0,0,0,3,116,237,177,232,0,49,4,0,0,0,0,0,0,49,8,0,0,0,0,4,254,226,104,72,0,50,4,0,0,0,18,250,0,50,8,0,0,0,0,2,253,209,210,136,0,51,4,0,0,0,8,125,0,52,4,0,0,3,153,24,0,53,4,0,0,0,3,184,0,61,4,0,0,0,27,7,0,61,8,0,0,0,0,2,129,145,17,112,0,62,4,0,0,0,0,0,0,62,8,0,0,0,0,3,97,206,185,184,0,63,4,0,0,0,0,0,0,63,8,0,0,0,0,0,12,209,223,216,0,64,4,0,0,0,13,202,0,64,8,0,0,0,0,7,162,189,108,224,0,69,4,0,0,0,30,88,0,69,8,0,0,0,0,7,185,245,7,96,0,70,4,0,0,0,0,0,0,70,8,0,0,0,0,3,176,182,65,24,0,71,4,0,0,0,13,71,0,72,4,0,0,3,146,152,0,73,4,0,0,0,3,123,144,0,0,0,2,8,5,82,0,0,0,0]",
        "payloadType": "bin",
        "x": 790,
        "y": 680,
        "wires": [
            [
                "84c219d9ed530b9b"
            ]
        ]
    },
    {
        "id": "84c219d9ed530b9b",
        "type": "buffer-parser",
        "z": "4726af68.c62a98",
        "name": "Messwerte",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "hex",
                "name": "serial",
                "offset": 20,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "P_bez",
                "offset": 32,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "P_ein",
                "offset": 52,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "Q_ind",
                "offset": 72,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "Q_kap",
                "offset": 92,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "S_bez",
                "offset": 112,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "S_ein",
                "offset": 132,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "cos_phi",
                "offset": 152,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "Hz",
                "offset": 160,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "P1_bez",
                "offset": 168,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "P1_ein",
                "offset": 188,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "Q1_ind",
                "offset": 208,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "Q1_kap",
                "offset": 228,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "S1_bez",
                "offset": 248,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "S1_ein",
                "offset": 268,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "I1",
                "offset": 288,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "U1",
                "offset": 296,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "cos_phi1",
                "offset": 304,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "P2_bez",
                "offset": 312,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "P2_ein",
                "offset": 332,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "Q2_ind",
                "offset": 352,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "Q2_kap",
                "offset": 372,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "S2_bez",
                "offset": 392,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "S2_ein",
                "offset": 412,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "I2",
                "offset": 432,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "U2",
                "offset": 440,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "cos_phi2",
                "offset": 448,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "P3_bez",
                "offset": 456,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "P3_ein",
                "offset": 476,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "Q3_ind",
                "offset": 496,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "Q3_kap",
                "offset": 516,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "S3_bez",
                "offset": 536,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "S3_ein",
                "offset": 556,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.1",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "I3",
                "offset": 576,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "U3",
                "offset": 584,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "uint32be",
                "name": "cos_phi3",
                "offset": 592,
                "length": 1,
                "offsetbit": 0,
                "scale": "0.001",
                "mask": ""
            },
            {
                "type": "hex",
                "name": "v1",
                "offset": 600,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "hex",
                "name": "v2",
                "offset": 601,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "hex",
                "name": "v3",
                "offset": 602,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "utf8",
                "name": "r",
                "offset": 603,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "resultType": "keyvalue",
        "resultTypeType": "output",
        "multipleResult": false,
        "fanOutMultipleResult": false,
        "setTopic": true,
        "outputs": 1,
        "x": 950,
        "y": 680,
        "wires": [
            [
                "7ee2b005b2e8b187"
            ]
        ]
    },
    {
        "id": "7ee2b005b2e8b187",
        "type": "function",
        "z": "4726af68.c62a98",
        "name": "Versionen",
        "func": "fw = msg.payload.v1 + \".\" + msg.payload.v2 + \".\" + msg.payload.v3 + \".\" + msg.payload.r;\nserial = parseInt(\"0x\"+msg.payload.serial);\nmsg.payload = {fw,serial};\nmsg.topic = \"Version\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1120,
        "y": 680,
        "wires": [
            [
                "09b9aeadc947081f"
            ]
        ]
    },
    {
        "id": "09b9aeadc947081f",
        "type": "debug",
        "z": "4726af68.c62a98",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1310,
        "y": 680,
        "wires": []
    }
]

it is hex "7159b5e4" = 1901704676

is it possible to decode the 1901704676 in the Buffer Parser ?
Without the function serial = parseInt("0x"+msg.payload.serial) ?

2nd question:
grafik
for what reason are "Property" and "Specification" in Buffer Parser?

Yes. Don't use "hex" type. Use a number type (probably uint32be)

Property is the incoming data. If you write parsers in series you might elect to have results stored in a different msg property like msg.data1 or msg.buffer etc so that payload is not overwritten.

Specification is for advanced dynamic use. In other words, you might need to build the buffer parser entries dynamically based on some logic it value. I think there is a demo in the built in examples.

1 Like

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