# Understanding Node-red-contrib-buffer-parser input values

**URL:** <https://discourse.nodered.org/t/understanding-node-red-contrib-buffer-parser-input-values/90649>\
**Category:** General\
**Created:** [2 September 2024 14:59 UTC](https://discourse.nodered.org/t/understanding-node-red-contrib-buffer-parser-input-values/90649 "2024-09-02T14:59:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeroenst](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeroenst/32/22682_2.png) [@jeroenst](https://discourse.nodered.org/u/jeroenst)\
**Post date:** [2 September 2024 14:59 UTC](https://discourse.nodered.org/t/understanding-node-red-contrib-buffer-parser-input-values/90649/1 "2024-09-02T14:59:04Z")

</div>

I use the Node-red-contrib-buffer-parser and it handles the data in de incoming array as 16 bit values. The offset is in 8 bits which I don't understand. And I also don't understand how this node determines if the incoming data is 8 or 16 bits per value in the array.

Can someone explain this to me?

---

<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:** [2 September 2024 15:46 UTC](https://discourse.nodered.org/t/understanding-node-red-contrib-buffer-parser-input-values/90649/2 "2024-09-02T15:46:19Z")

</div>

> [@jeroenst](#):
>
> The offset is in 8 bits which I don't understand

Under the hood, it uses the node [`Buffer`](https://nodejs.org/api/buffer.html) A Buffer is essentially a _fancy byte array_ :- 8 bits === 1 byte.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/c/fc9077661d8e066509aedf1854b55d4943d835cf.png)

The thing to remember is that under the hood, data is treated as a byte stream and therefore the `offset` is a byte index from the beginning of the byte stream from which to extract data. That makes it 100% universal and independent of the input data - it is ALWAYS a byte offset, the data is ALWAYS a byte stream.

> [@jeroenst](#):
>
> And I also don't understand how this node determines if the incoming data is 8 or 16 bits per value in the array.

- If input data is an array, the data is treated as 16 bit.
  - This is for simple and direct support of many 16 bit PLCs and in particular Modbus data.

- If input data is a `buffer`, the data is treated as 8 bit.
  - This is for everything else (like serial data streams etc)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7e208951f61cbf35659590e6fee97b1dc7d21ae7.png)

However, dont forget, as stated before, this is somewhat irrelevant since all data is treated as a byte array when it comes to the `offset`

---

<div class="post-metadata">

**Author:** ![jeroenst](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeroenst/32/22682_2.png) [@jeroenst](https://discourse.nodered.org/u/jeroenst)\
**Post date:** [2 September 2024 17:41 UTC](https://discourse.nodered.org/t/understanding-node-red-contrib-buffer-parser-input-values/90649/3 "2024-09-02T17:41:57Z")

</div>

Okay, thank you! Now it's clear to me!

---

<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:** [1 December 2024 17:42 UTC](https://discourse.nodered.org/t/understanding-node-red-contrib-buffer-parser-input-values/90649/4 "2024-12-01T17:42:02Z")

</div>

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