# Modbus communication buffer parser to bigint64

**URL:** <https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941>\
**Category:** Industrial\
**Created:** [28 October 2020 09:14 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941 "2020-10-28T09:14:53Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adri\_gl](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@Adri\_gl](https://discourse.nodered.org/u/Adri_gl)\
**Post date:** [28 October 2020 09:14 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/1 "2020-10-28T09:14:53Z")

</div>

i have problem converting to big integer from 4 element array like in picture. The configuration is as follows:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/7/277e1c828a3d3fb452342ecd56019a9c643e438a.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f14feb143fa24531ea0083ca1e0041289045cfc6.png)

when i convert to an int32 i have the data on the second item of the array, but when i convert to an bigInt, i get error parsing data

thanks.

---

<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:** [28 October 2020 09:17 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/2 "2020-10-28T09:17:27Z")

</div>

Can you export that flow please? Might be a bug.

Ps, you can't send int64 to debug window as node-red debug does not know how to deal with 64 bit numbers.

---

<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:** [28 October 2020 09:19 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/4 "2020-10-28T09:19:26Z")

</div>

Hi, in order to make code more readable and importable it is important to surround your code with three backticks  
`````  
`like this`  
`````

You can edit and correct your post by clicking the pencil icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![Adri\_gl](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@Adri\_gl](https://discourse.nodered.org/u/Adri_gl)\
**Post date:** [28 October 2020 09:20 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/5 "2020-10-28T09:20:31Z")

</div>

```auto
[{"id":"f8a6f9b0.a9a578","type":"inject","z":"7c82c2ee.793b8c","name":"","topic":"","payload":"[0,0,8020,4942]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":140,"wires":[["5730303.a981dd","f5f76e10.4fdd2"]]},{"id":"5730303.a981dd","type":"buffer-parser","z":"7c82c2ee.793b8c","name":"buffer to int32 lenght 2","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int32be","name":"Energía","offset":0,"length":2,"offsetbit":0,"scale":1,"mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":true,"setTopic":true,"x":500,"y":180,"wires":[["9da33f3.b272fc"]]},{"id":"f5f76e10.4fdd2","type":"buffer-parser","z":"7c82c2ee.793b8c","name":"buffer to big int 64 be","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"biguint64be","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":"output","multipleResult":false,"setTopic":true,"x":500,"y":120,"wires":[["90af94d9.74beb8"]]},{"id":"9da33f3.b272fc","type":"debug","z":"7c82c2ee.793b8c","name":"buffer parser","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":690,"y":180,"wires":[]},{"id":"90af94d9.74beb8","type":"debug","z":"7c82c2ee.793b8c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":690,"y":120,"wires":[]}]

```

---

<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:** [28 October 2020 09:28 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/6 "2020-10-28T09:28:52Z")

</div>

Works for me... (note the BigInt error as debug cannot show you the value)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6bb1ffc0ccf2d77523565d492e43af10eb22ee48.png)

What version of buffer-parser are you using? (current version is 2.5.1)  
What version of NODE are you using? (bigInt requires nodejs \>= 10.4.0)

---

<div class="post-metadata">

**Author:** ![Adri\_gl](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@Adri\_gl](https://discourse.nodered.org/u/Adri_gl)\
**Post date:** [28 October 2020 09:36 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/7 "2020-10-28T09:36:28Z")

</div>

The buffer-parser version is the current, so that's ok  
the nodejs version is 8.16.0 and it's the highest version that i can use.  
i installed npm big-integer and added bigInt:require ("big-integer") into settings.js

---

<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:** [28 October 2020 09:38 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/8 "2020-10-28T09:38:37Z")

</div>

> [@Adri\_gl](#):
>
> the nodejs version is 8.16.0 and it's the highest version that i can use

Why is that? Are you 100% sure?

  

> [@Adri\_gl](#):
>
> i installed npm big-integer and added bigInt:require ("big-integer") into settings.js

I dont think that is enough (BigInt is native) (I could be wrong)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 October 2020 09:44 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/9 "2020-10-28T09:44:14Z")

</div>

BigInt only became native in nodejs 10.4.0

---

<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:** [28 October 2020 09:47 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/10 "2020-10-28T09:47:35Z")

</div>

I am tempted to look at using `require ("big-integer")` if node-js is \< v 10.4.0 then I am thinking restrict `buffer-parser` to nodejs \>= 10.4.0 then I am thinking leave it as is 🤔 🤔 🤔

Advice Dave?

---

<div class="post-metadata">

**Author:** ![Adri\_gl](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@Adri\_gl](https://discourse.nodered.org/u/Adri_gl)\
**Post date:** [28 October 2020 09:53 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/11 "2020-10-28T09:53:14Z")

</div>

> [@Steve-Mcl](#):
>
> Why is that? Are you 100% sure?

for the iot2040, yes.

> [@Steve-Mcl](#):
>
> I dont think that is enough (BigInt is native) (I could be wrong)

you're right

---

<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:** [28 October 2020 10:02 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/12 "2020-10-28T10:02:58Z")

</div>

As a temporary workaround, you could use your `require ("big-integer")` in a function and convert the 2 32bit values.

As for nodejs on IOT box - you have a few of options

- replace it with a sensible priced (but more performant) box like a Rasperry Pi 4
- hack it
- complain about it to siemens and your IT secuirty team about it being a potential seurity risk due to [Node V8 EOL](https://blog.risingstack.com/update-nodejs-8-end-of-life-no-support/#:~:text=Start%20upgrading%20Node.-,js%208%20now!,exposed%20to%20otherwise%20avoidable%20threats.)

---

<div class="post-metadata">

**Author:** ![Adri\_gl](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@Adri\_gl](https://discourse.nodered.org/u/Adri_gl)\
**Post date:** [28 October 2020 10:06 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/13 "2020-10-28T10:06:52Z")

</div>

thank you very much for your help.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 October 2020 11:17 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/14 "2020-10-28T11:17:30Z")

</div>

As usual... it's your node so up to you :-)... Basically you are right - node 8 is beyond end of life so there is no reason to retrofit functionality if you don't want to. In the core project we are (hopefully - best efforts) maintaining node8 compatibility until our version 2 (1/2Q 2021).

---

<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:** [27 December 2020 11:17 UTC](https://discourse.nodered.org/t/modbus-communication-buffer-parser-to-bigint64/34941/15 "2020-12-27T11:17:32Z")

</div>

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