# ModBus TCP Read 64-bit registers

**URL:** <https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402>\
**Category:** Industrial\
**Created:** [24 April 2020 07:11 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402 "2020-04-24T07:11:39Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 April 2020 09:36 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/22 "2020-04-24T09:36:21Z")

</div>

> [@Steve-Mcl](#):
>
> what version of nodejs are you using?

@Steve-Mcl the flow is using `readBigInt64BE` so it must be node 12 or later.

As I've already said, the problem here is what the flow is trying to do with the result of `readBigInt64BE`.

@Job-Hoogeboom in your screenshot we can see the errors, but we cannot see what node has reported them. Can you tell us which nodes are logging these errors? Click on the node ids I've highlighted.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a8e9123b108f50dafcb4e7fcfd7efe3f068e4bb3.png)

You have the `Datacake Parser` function in an earlier screenshot that is not in the flow json you've shared. What is that function doing?

---

<div class="post-metadata">

**Author:** ![Job-Hoogeboom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/job-hoogeboom/32/19629_2.png) [@Job-Hoogeboom](https://discourse.nodered.org/u/Job-Hoogeboom)\
**Post date:** [24 April 2020 09:36 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/23 "2020-04-24T09:36:58Z")

</div>

that can be possible, it does seem like it reads the value correctly.

 ![......PNG](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/d/4d4539b2a81d7b73cf02200882b226dfc93a365f.png)

---

<div class="post-metadata">

**Author:** ![Job-Hoogeboom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/job-hoogeboom/32/19629_2.png) [@Job-Hoogeboom](https://discourse.nodered.org/u/Job-Hoogeboom)\
**Post date:** [24 April 2020 09:38 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/24 "2020-04-24T09:38:31Z")

</div>

> in your screenshot we can see the errors, but we cannot see what node has reported them. Can you tell us which nodes are logging these errors? Click on the node ids I've highlighted.

I'll give them separate names. 🙂

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 April 2020 09:39 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/25 "2020-04-24T09:39:11Z")

</div>

> [@Job-Hoogeboom](#):
>
> I'll give them separate names.

That is a good idea for the future - but right now, can you tell us what your Function node is doing?

---

<div class="post-metadata">

**Author:** ![Job-Hoogeboom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/job-hoogeboom/32/19629_2.png) [@Job-Hoogeboom](https://discourse.nodered.org/u/Job-Hoogeboom)\
**Post date:** [24 April 2020 09:40 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/26 "2020-04-24T09:40:54Z")

</div>

![Knipsel](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9e4c02c8b72055819113c2b34b3316a16b13c91b.png)

---

<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:** [24 April 2020 09:40 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/27 "2020-04-24T09:40:58Z")

</div>

Nick, looks to me like its just the debug node...

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

I faked some data and it works - the error is from the debug node

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 April 2020 09:43 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/28 "2020-04-24T09:43:41Z")

</div>

Ok - so we need to fix that in the Debug node.

So, ignoring the Debug node for the moment, @Job-Hoogeboom is your flow now working? What do you want to do with the data after reading it?

---

<div class="post-metadata">

**Author:** ![Job-Hoogeboom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/job-hoogeboom/32/19629_2.png) [@Job-Hoogeboom](https://discourse.nodered.org/u/Job-Hoogeboom)\
**Post date:** [24 April 2020 09:47 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/29 "2020-04-24T09:47:02Z")

</div>

Ill 'try to copy the string in @Steve-Mcl screenshot into mine.

@knolleary The data gets forwarded via https to a cloud service called Datacake. the data gets stored and visualized in there.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 April 2020 09:50 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/30 "2020-04-24T09:50:04Z")

</div>

> [@Job-Hoogeboom](#):
>
> Ill 'try to copy the string in @Steve-Mcl screenshot into mine.

The code in Steve screenshot was just to simulate what you are doing to show there's a problem with the Debug node. It wasn't code for you to copy.

Now we know the Debug node can't handle BigInt, we can ignore the error it is produce - it won't affect your flow from trying the HTTP request to Datacake.

So where have you got to with that part? Is it working?

---

<div class="post-metadata">

**Author:** ![Job-Hoogeboom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/job-hoogeboom/32/19629_2.png) [@Job-Hoogeboom](https://discourse.nodered.org/u/Job-Hoogeboom)\
**Post date:** [24 April 2020 09:56 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/31 "2020-04-24T09:56:54Z")

</div>

> The code in Steve screenshot was just to simulate what you are doing to show there's a problem with the Debug node. It wasn't code for you to copy.

Sorry understood it wrong,

It seems that the http request node doesn't know how to deal with the BigInt to.

 ![http error](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/d/2db30e76c244d7b82d216dd042cc8014077d29c3.png)

---

<div class="post-metadata">

**Author:** ![Job-Hoogeboom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/job-hoogeboom/32/19629_2.png) [@Job-Hoogeboom](https://discourse.nodered.org/u/Job-Hoogeboom)\
**Post date:** [24 April 2020 09:58 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/32 "2020-04-24T09:58:14Z")

</div>

maybe the BigInt value needs to be decoded to a normal value that the debug and http node can understand.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 April 2020 10:03 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/33 "2020-04-24T10:03:36Z")

</div>

> [@Job-Hoogeboom](#):
>
> maybe the BigInt value needs to be decoded to a normal value

Yes - you can use `parseInt(value)` to convert a BigInt to a Number type that can be serialised into JSON.

But I don't know what the behaviour will be if the BigInt value is bigger than a Number can hold.

---

<div class="post-metadata">

**Author:** ![Job-Hoogeboom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/job-hoogeboom/32/19629_2.png) [@Job-Hoogeboom](https://discourse.nodered.org/u/Job-Hoogeboom)\
**Post date:** [24 April 2020 10:08 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/34 "2020-04-24T10:08:27Z")

</div>

I guess we'll try and see 😉 Can you maybe help with an example of the function node with the parseInt(value) in it?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 April 2020 10:10 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/35 "2020-04-24T10:10:09Z")

</div>

```auto
...
const value = parseInt(buf.readBigInt64BE())
...

```

---

<div class="post-metadata">

**Author:** ![Job-Hoogeboom](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/job-hoogeboom/32/19629_2.png) [@Job-Hoogeboom](https://discourse.nodered.org/u/Job-Hoogeboom)\
**Post date:** [24 April 2020 10:14 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/36 "2020-04-24T10:14:58Z")

</div>

Super! I can receive the kWh in Datacake now! Thanks for the help and time! @knolleary and, @Steve-Mcl

---

<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:** [23 June 2020 10:15 UTC](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402/37 "2020-06-23T10:15:00Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/modbus-tcp-read-64-bit-registers/25402.md?page=1)
