Modbus communication buffer parser to bigint64

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


image

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.

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.

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

[{"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":[]}]

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

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)

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

Why is that? Are you 100% sure?


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

BigInt only became native in nodejs 10.4.0

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 :thinking: :thinking: :thinking:

Advice Dave?

for the iot2040, yes.

you're right

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

thank you very much for your help.

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).

1 Like