# Uint32 (sw) in node-red-contrib-buffer-parser or alternative?

**URL:** <https://discourse.nodered.org/t/uint32-sw-in-node-red-contrib-buffer-parser-or-alternative/101078>\
**Category:** General\
**Created:** [19 May 2026 16:41 UTC](https://discourse.nodered.org/t/uint32-sw-in-node-red-contrib-buffer-parser-or-alternative/101078 "2026-05-19T16:41:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rucksman007](https://avatars.discourse-cdn.com/v4/letter/r/a88e4f/32.png) [@rucksman007](https://discourse.nodered.org/u/rucksman007)\
**Post date:** [19 May 2026 16:41 UTC](https://discourse.nodered.org/t/uint32-sw-in-node-red-contrib-buffer-parser-or-alternative/101078/1 "2026-05-19T16:41:30Z")

</div>

I am using node-red-contrib-buffer-parser to parse a long buffer that I recieve via Modbus. It is a mix of (u)int16 und (u)int32 values. As the documentation for this device does not say anything about endianess I used big endian for the (u)int16 values which worked fine. But the (u)int32 values are wrong. I would need to swap bytes which would give me correct values for the (u)int32 values but would mess up all the other values. Is there a way to swap bytes on a per-value-basis? A type uint32sw would be great. Of course I could make a workaround and do two (u)int16 values and calculate the correct value afterwards in a function node, but my goal was to get all values from the buffer parser node.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 May 2026 20:04 UTC](https://discourse.nodered.org/t/uint32-sw-in-node-red-contrib-buffer-parser-or-alternative/101078/2 "2026-05-19T20:04:17Z")

</div>

Are you certain you are correctly aligned on the byte marks?

A work around would be to feed the data through 2 parsers. You can either do it in parallel (then use a join node after) or in series by adding an entry in the first that outputs the full buffer (use -1 for the length) then apply swaps in the 2nd parser.

---

<div class="post-metadata">

**Author:** ![hipatel93](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hipatel93](https://discourse.nodered.org/u/hipatel93)\
**Post date:** [20 May 2026 05:25 UTC](https://discourse.nodered.org/t/uint32-sw-in-node-red-contrib-buffer-parser-or-alternative/101078/3 "2026-05-20T05:25:28Z")

</div>

have to read what kind of data is sent by your device over Modbus. Personally, I do not buffer parser. I will type my own custom JavaScript to convert data, which is faster than Buffer.

This is an example script for you:

```auto
// 4. Decoding Helper Functions
function decodeFloat(lowWord, highWord) {
    const buf = new ArrayBuffer(4);
    const view = new DataView(buf);
    view.setUint16(0, highWord, false);
    view.setUint16(2, lowWord, false);
    return Math.round(view.getFloat32(0, false) * 1000) / 1000;
}

function decodeInt32(lowWord, highWord) {
    let u = ((highWord & 0xFFFF) << 16) | (lowWord & 0xFFFF);
    return u >> 0;
}

function decodeUint32(lowWord, highWord) {
    return ((highWord & 0xFFFF) * 65536) + (lowWord & 0xFFFF);
}

function decodeBCD(w) {
    return ((w >> 12) & 0xF) * 1000 + ((w >> 8) & 0xF) * 100 + ((w >> 4) & 0xF) * 10 + (w & 0xF);
}

function decodeBool(w, bit) {
    return ((w >> bit) & 1) === 1;
}

```

---

<div class="post-metadata">

**Author:** ![rucksman007](https://avatars.discourse-cdn.com/v4/letter/r/a88e4f/32.png) [@rucksman007](https://discourse.nodered.org/u/rucksman007)\
**Post date:** [20 May 2026 14:41 UTC](https://discourse.nodered.org/t/uint32-sw-in-node-red-contrib-buffer-parser-or-alternative/101078/4 "2026-05-20T14:41:27Z")

</div>

Thanks for helping. @hipatel93 I did the parsing in another flow like you do, but as this flow delivers a lot of data from the modbus flex getter node, I wanted to use the buffer parser node to keep it simpler and in a more maintainable more compared to a long function node. But maybe the easier handling of the different values speaks for the function node. @Steve-Mcl The uint16(be) values are fine without swapping, but the uint32(be) would need to be swapped. I checked this against the real values I get from the (closed source) app of the manufacturer of the device. The idea of using two buffer parser nodes in series would be worth considering though.

Update: two buffer parser nodes are not a solution as the swap option would swap the entire buffer and therefor the addresses would be wrong.

---

<div class="post-metadata">

**Author:** ![hipatel93](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hipatel93](https://discourse.nodered.org/u/hipatel93)\
**Post date:** [27 May 2026 22:38 UTC](https://discourse.nodered.org/t/uint32-sw-in-node-red-contrib-buffer-parser-or-alternative/101078/5 "2026-05-27T22:38:16Z")

</div>

> [@rucksman007](#):
>
> e uint16(be) values are fine without swapping, but the uint32(be) would need to be swapped. I checked this against the real values I get from the (closed source) app of the manufacturer of the device. The idea of using two buffer parser nodes in series would be worth considering though.
> 
> Update: two buffer parser nodes are not a solution as the swap option would swa

What I did in this case was map all my key details, and when I read, I pass the payload to the function with this data conversion and call tagmap; it will recognize what kind of data needs to be converted and stored in global, just like other runtime/SCADA software works.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 August 2026 22:38 UTC](https://discourse.nodered.org/t/uint32-sw-in-node-red-contrib-buffer-parser-or-alternative/101078/6 "2026-08-25T22:38:39Z")

</div>

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