RangeError: The value of "offset" is out of range. It must be >= 0 and <= 0. Received 1

Could anyone please help me to resolve below error please.

RangeError: The value of "offset" is out of range. It must be >= 0 and <= 0. Received 1

Welcome to the forum @Mayur

Which node is generating the error? Click on the node id in the debug pane ant it will show you. It is a good idea to give significant nodes names so that it is easier to identify them.
Are you using the latest versions of all nodes? Check in Manage Palette.

Also tell us which versions of node red (seen at the bottom of the dropdown menu) and which version of nodejs (in a command window run node -v to find out).

The data going in to buffer-parser is not suitable for the settings you have in the buffer-parser node.

Export the share buffer parser (CTRL-E) so we can see what you have set

A screenshot of the export process is not going to help I am afraid. We need the actual flow JSON it exports to be able to help.

  1. Click + Select the buffer-parser nodes
  2. Press ctrl+e
  3. Click "Copy to Clipboard"
  4. Paste the export into a code block in a reply
[
    {
        "id": "2d2ffc8049288890",
        "type": "buffer-parser",
        "z": "129ad6e53bd2b94a",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "floatbe",
                "name": "item1",
                "offset": 0,
                "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": 110,
        "y": 680,
        "wires": [
            [
                "170e1f1f15dbc9c5"
            ]
        ]
    }
]

admin edit: wrap flow JSON in triple backtick code block

That buffer parser works with the data you showed in your first screenshot:

but I doubt it is the value you expected!

Q: What is the expected value supposed to be?
Q: What is the specification of the register you are reading? Int32? Float32? UINT16 divided by 10? etc etc

flow for the above demo (use CTRL-I to import)

[{"id":"2d2ffc8049288890","type":"buffer-parser","z":"99e019d5.6f0748","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatbe","name":"item1","offset":0,"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":750,"y":640,"wires":[["aef1dfab318f76ef"]]},{"id":"4d977988ba601fa7","type":"inject","z":"99e019d5.6f0748","name":"fake modbus data [43586,16818]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[43586,16818]","payloadType":"json","x":510,"y":640,"wires":[["2d2ffc8049288890"]]},{"id":"aef1dfab318f76ef","type":"debug","z":"99e019d5.6f0748","name":"debug 19","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":920,"y":640,"wires":[]}]

We are trying to fetch WirelessHART data via MODBUS TCP IP protocol as per below:

PAT-WVM-01.PV | 40001 | | FALSE|

Which is 32 bits (float)

Please answer other question

e.g. PAT-WVM-01.PV, Register 40001 with a data value of [43586,16818] should be parsed to xx.xxx ???

i.e. What is a realistic looking final/parsed value for this register?

More questions:

  1. What version of NodeJS is Node-RED running on
    1. node -v
  2. What version of Node-RED is this (see top-right hamburger menu)
  3. What version of buffer-parser are you using (your screenshot does not show this)
    1. image


Value of PV SV TV QV shown in Gateway (As per attached image) needs to be fetch to Node Red in Debug

  1. Node JS version: v20.13.1
  2. Node Red Version: v3.02

It looks like the data is little endian and byte swapped!.


That is quite messy! You will need to swap all data and use the LE functions.
(most modbus data I have encountered is not byteswapped and uses the BE (Big Endian) options)

Looking at a random manual i found, your gateway supports setting the endianess - I probably would recommend you swap at source.


Demo flow for the above screenshot:

[{"id":"e8532cf0f31832d9","type":"buffer-parser","z":"99e019d5.6f0748","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"float","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","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":750,"y":740,"wires":[["7321be9f1e43adca"]]},{"id":"7321be9f1e43adca","type":"debug","z":"99e019d5.6f0748","name":"debug 20","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":920,"y":740,"wires":[]},{"id":"2ea9c23b3c030ad7","type":"inject","z":"99e019d5.6f0748","name":"fake modbus data [3612,16825]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[3612,16825]","payloadType":"json","x":510,"y":740,"wires":[["e8532cf0f31832d9"]]}]

I see you have started a new thread. Does that mean my previous post helped you solve this problem? If so, please mark it as a solution so that it can help future readers with the same problem.