Modbus_assign a string to different int-values

Hello.

I hope my topic is kinda right. I am experimenting with MODBUS (again).
Today i try to read a WarningCode and an AlarmCode from my pump via MODBUS.

There a 2 adresses to read out warning and Alarm.

Alarm = 216
Warning 217

Depedning on the type of alarm or warning, the respective adress gives different integers.
for example for adress 217 (warning): 208 (error 1), 57 (error 2) ... and so on..

My question now: I know i could do it with a simple function and if statements. I read the more "elegant" way for such scenarios is to user buffersparser. Now i am a bit confused how to user the bufferparser so assgin the integer to a string-output(errormessage).

[
    {
        "id": "916fba86ba4e53b4",
        "type": "modbus-flex-getter",
        "z": "4b39b758866405c2",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "logIOActivities": false,
        "server": "0e3ec676f3e39293",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "x": 1740,
        "y": 180,
        "wires": [
            [
                "9839a3a7df26be41",
                "191f1d8a2c779968"
            ],
            []
        ]
    },
    {
        "id": "9839a3a7df26be41",
        "type": "modbus-response",
        "z": "4b39b758866405c2",
        "name": "",
        "registerShowMax": 20,
        "x": 1760,
        "y": 100,
        "wires": []
    },
    {
        "id": "a5ccc76734177a20",
        "type": "function",
        "z": "4b39b758866405c2",
        "name": "Read_216",
        "func": "msg.payload =\n{\n    value: msg.payload,\n    'fc': 3,\n    'unitid': 0,\n    'address': 216,\n    'quantity': 2\n\n};\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1530,
        "y": 180,
        "wires": [
            [
                "916fba86ba4e53b4"
            ]
        ]
    },
    {
        "id": "ba033e6638e9c713",
        "type": "inject",
        "z": "4b39b758866405c2",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "2",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 1340,
        "y": 180,
        "wires": [
            [
                "a5ccc76734177a20"
            ]
        ]
    },
    {
        "id": "191f1d8a2c779968",
        "type": "buffer-parser",
        "z": "4b39b758866405c2",
        "name": "buffer parser",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "int16be",
                "name": "AlarmCode",
                "offset": 1,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "string",
                "name": "WarningCode",
                "offset": 2,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "resultType": "keyvalue",
        "resultTypeType": "return",
        "multipleResult": false,
        "fanOutMultipleResult": false,
        "setTopic": true,
        "outputs": 1,
        "x": 2010,
        "y": 180,
        "wires": [
            [
                "a900d3925b31634f"
            ]
        ]
    },
    {
        "id": "a900d3925b31634f",
        "type": "debug",
        "z": "4b39b758866405c2",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 2180,
        "y": 100,
        "wires": []
    },
    {
        "id": "0e3ec676f3e39293",
        "type": "modbus-client",
        "name": "CIM500",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "tcpHost": "10.240.6.39",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "0x3A",
        "unit_id": "1",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": true,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true
    }
]

Thank you

Hello Manuel .. you cannot do this with buffer-parser, as far as i know.
buffer-parser does its job converting the buffer from Modbus to whatever type the value is ( int in this case )
and its up to you to later re-assign those integers to an actual human readable error.

As you suggested a Function node after buffer-parser is a good way.

thank your again to all for the reply. I ve done it with functions at the end. =)

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