How to extract nibble data in buffer-parser

Good day,

I am looking for some help to extract nibble data coming from a DSE Generator controller over Modbus.

I did see the option to use BCD but not sure how to properly use it in the configuration.

I have attached the code I have created so far (I had to remove lines from the buffer-parser to get it posted). I read 10 sets of registers from the controller, join the 10 buffer messages and the send it to the buffer-parser. From the buffer-parser I package the data and MQTT it. I would prefer not to do another function to extract the nibble data.

[
    {
        "id": "7d4768579567f426",
        "type": "subflow",
        "name": "Decode DSE",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 50,
                "y": 30,
                "wires": [
                    {
                        "id": "d2f24a86f8a7cdd2"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 500,
                "y": 30,
                "wires": [
                    {
                        "id": "0758e7430acbd47d",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "0758e7430acbd47d",
        "type": "function",
        "z": "7d4768579567f426",
        "name": "Package data",
        "func": "var vMetrics = [];\nvar vTemp = {};\nfor (const x in msg.payload) {\n    vTemp = {\n        \"name\" : msg.payload[x].name, \n        \"value\" : msg.payload[x].value,\n        \"type\" : msg.payload[x].scale === \"1\" ? \"int\" : \"float\"\n        }\n    vMetrics.push(vTemp);\n}\n\nvar mqtt_b = {\n    \"timestamp\" : msg.payload.timestamp !== undefined ? msg.payload.timestamp : new Date().getTime(),\n    \"metrics\" : vMetrics\n};\n\nmsg.payload = mqtt_b;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 365,
        "y": 30,
        "wires": [
            []
        ]
    },
    {
        "id": "d2f24a86f8a7cdd2",
        "type": "buffer-parser",
        "z": "7d4768579567f426",
        "name": "DSE 8620",
        "data": "payload.buffer",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "uint16be",
                "name": "Alarm Conditions/Number of Named Alarms",
                "offset": 430,
                "length": 1,
                "offsetbit": 13,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "bcdbe",
                "name": "Alarm Conditions/Emergency Stop",
                "offset": 432,
                "length": 1,
                "offsetbit": 13,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "resultType": "object",
        "resultTypeType": "output",
        "multipleResult": false,
        "fanOutMultipleResult": false,
        "setTopic": true,
        "outputs": 1,
        "x": 175,
        "y": 30,
        "wires": [
            [
                "0758e7430acbd47d"
            ]
        ]
    },
    {
        "id": "a87ad26554f8cf59",
        "type": "subflow",
        "name": "Registers DSE",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 35,
                "y": 30,
                "wires": [
                    {
                        "id": "7ed6566181fe9392"
                    },
                    {
                        "id": "b0476d96a04c2bcd"
                    },
                    {
                        "id": "b54d756e7ac2ccf3"
                    },
                    {
                        "id": "06f45dd7a03d5be7"
                    },
                    {
                        "id": "7db6785dd32d217d"
                    },
                    {
                        "id": "da0d91864247f292"
                    },
                    {
                        "id": "5a2a17229c26559a"
                    },
                    {
                        "id": "752a00692e27a420"
                    },
                    {
                        "id": "423a1ac5d9a18284"
                    },
                    {
                        "id": "6b48e963d0c56a00"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 680,
                "y": 30,
                "wires": [
                    {
                        "id": "7ed6566181fe9392",
                        "port": 0
                    },
                    {
                        "id": "b0476d96a04c2bcd",
                        "port": 0
                    },
                    {
                        "id": "b54d756e7ac2ccf3",
                        "port": 0
                    },
                    {
                        "id": "06f45dd7a03d5be7",
                        "port": 0
                    },
                    {
                        "id": "7db6785dd32d217d",
                        "port": 0
                    },
                    {
                        "id": "da0d91864247f292",
                        "port": 0
                    },
                    {
                        "id": "5a2a17229c26559a",
                        "port": 0
                    },
                    {
                        "id": "752a00692e27a420",
                        "port": 0
                    },
                    {
                        "id": "423a1ac5d9a18284",
                        "port": 0
                    },
                    {
                        "id": "6b48e963d0c56a00",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "7ed6566181fe9392",
        "type": "function",
        "z": "a87ad26554f8cf59",
        "name": "Page 3:4",
        "func": "msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 10,\n    'address': (3*256)+4,\n    'quantity': 3\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 165,
        "y": 30,
        "wires": [
            []
        ]
    },
    {
        "id": "b0476d96a04c2bcd",
        "type": "function",
        "z": "a87ad26554f8cf59",
        "name": "Page 4",
        "func": "msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 10,\n    'address': (4*256),\n    'quantity': 95\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 180,
        "y": 75,
        "wires": [
            []
        ]
    },
    {
        "id": "b54d756e7ac2ccf3",
        "type": "function",
        "z": "a87ad26554f8cf59",
        "name": "Page 5:16",
        "func": "msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 10,\n    'address': (5*256)+16,\n    'quantity': 2\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 205,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "06f45dd7a03d5be7",
        "type": "function",
        "z": "a87ad26554f8cf59",
        "name": "Page 6",
        "func": "msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 10,\n    'address': (6*256),\n    'quantity': 85\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 210,
        "y": 165,
        "wires": [
            []
        ]
    },
    {
        "id": "7db6785dd32d217d",
        "type": "function",
        "z": "a87ad26554f8cf59",
        "name": "Page 7:6",
        "func": "msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 10,\n    'address': (7*256)+6,\n    'quantity': 36-6\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 225,
        "y": 210,
        "wires": [
            []
        ]
    },
    {
        "id": "da0d91864247f292",
        "type": "function",
        "z": "a87ad26554f8cf59",
        "name": "Page 8",
        "func": "msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 10,\n    'address': (8*256),\n    'quantity': 26\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 240,
        "y": 255,
        "wires": [
            []
        ]
    },
    {
        "id": "752a00692e27a420",
        "type": "function",
        "z": "a87ad26554f8cf59",
        "name": "Page 11:3",
        "func": "msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 10,\n    'address': (11*256)+3,\n    'quantity': 1\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 270,
        "y": 345,
        "wires": [
            []
        ]
    },
    {
        "id": "423a1ac5d9a18284",
        "type": "function",
        "z": "a87ad26554f8cf59",
        "name": "Page 12",
        "func": "msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 10,\n    'address': (12*256),\n    'quantity': 2\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 285,
        "y": 390,
        "wires": [
            []
        ]
    },
    {
        "id": "6b48e963d0c56a00",
        "type": "function",
        "z": "a87ad26554f8cf59",
        "name": "Page 13",
        "func": "msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 10,\n    'address': (13*256),\n    'quantity': 1\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 300,
        "y": 435,
        "wires": [
            []
        ]
    },
    {
        "id": "5a2a17229c26559a",
        "type": "function",
        "z": "a87ad26554f8cf59",
        "name": "Page 10:6",
        "func": "msg.payload = {\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 10,\n    'address': (10*256)+6,\n    'quantity': 1\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 265,
        "y": 300,
        "wires": [
            []
        ]
    },
    {
        "id": "655b72f11c13813b",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "0a9b271059a0258c",
        "type": "inject",
        "z": "655b72f11c13813b",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 90,
        "y": 30,
        "wires": [
            [
                "f1b8ac0e01d883c6"
            ]
        ]
    },
    {
        "id": "f1b8ac0e01d883c6",
        "type": "subflow:a87ad26554f8cf59",
        "z": "655b72f11c13813b",
        "name": "",
        "x": 250,
        "y": 30,
        "wires": [
            [
                "63b6f338a8d234d2"
            ]
        ]
    },
    {
        "id": "63b6f338a8d234d2",
        "type": "function",
        "z": "655b72f11c13813b",
        "name": "Topic",
        "func": "msg.topic = \"Generator1/DBIRTH\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 30,
        "wires": [
            [
                "76e3bb5df473789f",
                "c90eab1c02695fbe"
            ]
        ]
    },
    {
        "id": "76e3bb5df473789f",
        "type": "modbus-flex-getter",
        "z": "655b72f11c13813b",
        "name": "Generator",
        "showStatusActivities": true,
        "showErrors": true,
        "logIOActivities": false,
        "server": "d6e7c1d583cd4fa2",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "keepMsgProperties": true,
        "x": 525,
        "y": 60,
        "wires": [
            [
                "c90eab1c02695fbe"
            ],
            [
                "d58b48a995497752"
            ]
        ]
    },
    {
        "id": "d58b48a995497752",
        "type": "join",
        "z": "655b72f11c13813b",
        "name": "",
        "mode": "custom",
        "build": "buffer",
        "property": "payload.buffer",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "1",
        "count": "10",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 670,
        "y": 75,
        "wires": [
            [
                "c90eab1c02695fbe",
                "684eaeb3ecd4b689"
            ]
        ]
    },
    {
        "id": "684eaeb3ecd4b689",
        "type": "subflow:7d4768579567f426",
        "z": "655b72f11c13813b",
        "name": "",
        "x": 875,
        "y": 90,
        "wires": [
            [
                "c90eab1c02695fbe"
            ]
        ]
    },
    {
        "id": "c90eab1c02695fbe",
        "type": "debug",
        "z": "655b72f11c13813b",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 875,
        "y": 30,
        "wires": []
    },
    {
        "id": "d6e7c1d583cd4fa2",
        "type": "modbus-client",
        "name": "DSE 88.100",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": true,
        "queueLogEnabled": true,
        "failureLogEnabled": true,
        "tcpHost": "192.168.88.100",
        "tcpPort": "502",
        "tcpType": "TCP-RTU-BUFFERED",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "0x3A",
        "unit_id": "10",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": true,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true
    }
]

Try...

1 Like

Thank you, will try that.

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