Bufferparser with U64 Modbus

First off, lets verify things.

Please confirm nodejs version and node-red version by posting the first 10 lines or so after node-red starts - should look like this...

Starting as a systemd service.
9 Dec 09:37:35 - [info]
Welcome to Node-RED
===================
9 Dec 09:37:35 - [info] Node-RED version: v1.2.6
9 Dec 09:37:35 - [info] Node.js  version: v14.15.1
9 Dec 09:37:35 - [info] Linux 5.4.79-v7+ arm LE
9 Dec 09:37:36 - [info] Loading palette nodes
9 Dec 09:37:41 - [info] Settings file  : /home/pi/.node-red/settings.js
9 Dec 09:37:41 - [info] Context store  : 'default' [module=memory]
9 Dec 09:37:41 - [info] User directory : /home/pi/.node-red
9 Dec 09:37:41 - [warn] Projects disabled : editorTheme.projects.enabled=false
9 Dec 09:37:41 - [info] Flows file     : /home/pi/.node-red/flows_raspberrypi.json
9 Dec 09:37:41 - [info] Server now running at http://127.0.0.1:1880/

What is a "course"?

Gonna need more detail.

Post an annotated screenshot with arrows and text describing what should happen where

And dont worry, we will get you up and running again.

I got it, just moved in a other dashboard and back -> everything back :slightly_smiling_face:

The NibePI Master** isn´t running correctly, so I makes no sense to try a new Buster+NR + worry²
for example the config can´t be edited, after reboot its clear... Can´t read any Nibe Registers.

npm install --save anerdins/node-red-contrib-nibepi#master

So are you now fully updated (node and node-red) and working?

Are the BigInt demos posted earlier now working?

Nope everything back to 1.0.6 (never change a running system).

If I´ll try a new attempt,only with a 2nd SD-Card ! Such a mess like yesterday! Never again

1 Like

Do you mean the config cannot be accessed? or the config page is blank? Please be more specific - we might be able to help.

clear fields or completely blank UI? or back to default settings?

Because its not communicating? or because config doesnt "stick"?

There might be simple solutions. There may be need for the developer to update his code - without properly documenting or at least providing screenshots of what is going on, it will be difficult to resolve.

This is how we learn. This is how we all become proficient. Its part of the fun.
As they say - "no pain no gain"

/etc/nibepi/config.json:


this is the config I spoke about.

Installing NibePi by:

npm install --save anerdins/node-red-contrib-nibepi#master

is completely different.

If I change something in it, after reboot it is default.

In the finished image that I'm using, I've never had to go in there to change anything!
As soon as I query a new register, it is written in the config (don´t know how) - as you see in the first screenshot.
I think only the developer can help. Or you (Steve) need to buy a Nibe Heatpump :joy:

Can you reveal me, how I can copy the config file to my windows pc?

Sure LMGTFY

Got it, with WinSCP.exe

run SCP from your windows pc

If I have more informations from Mr. Anderdins and a 2nd SD-Card, I´ll get in touch again here :wink:
thank you so far

I also got the tip that a read only system is not that easy to create. NibePi (image) is read only.

Now the values are to big for 16bit:

[0,0,1,3501,0,0,0,52239]

I tried the buffer parser, but I don´t get the correct value with 32bit.
Any idea with 32bit ?

16 bit UINT max is 65535

using 32bit would encroach on other data and give you the wrong value (as you see)

what does the SPEC say for this item?

so it only works with a 64bit buffer parser :worried:

not enough info

  • are you now running newer NODE JS version?
  • What only works with "64bit buffer parser"

you need to provide details (we are not psycic)

can I somehow get the correct value without 64bit bp?

I bought a new SD-card for trying Buster with Node RED and Nibe Pi, but I'm not ready yet.

Picture ist from post #1.

You can paste images directly into a reply (no need to upload anywhere first)

I thought you were getting a new SD card an upgrading? What happened to that?

If you provide a sample of data to inject and the relevant details (like the byte position of where this 64 bit data is) I will try to fabricate the result for you using 2 32bit reads,

I did:

[0,0,1,3501,0,0,0,52239]

first value: 0 - 0 - 1 - 3501 => 690xx (xx = 0 till 19)
sec. value: 0 - 0 - 0 - 52239 => 52239 already

this comes from modbus read

that is not a buffer. Buffer would have 16 bytes from 0~255

{"topic":"cd1d4476.573438","messageId":"5fdcba413f27802973d6dffb","payload":[0,0,1,3501,0,0,0,52479],"queueLengthByUnitId":{"unitId":3,"queueLength":0},"queueUnitId":3,"unitId":3,"modbusRequest":{"value":{"IS":5.726},"unitid":"3","fc":4,"address":"31397","quantity":"8","messageId":"5fdcba413f27802973d6dffb"},"responseBuffer":{"data":[0,0,1,3501,0,0,0,52479],"buffer":[0,0,0,0,0,1,13,173,0,0,0,0,0,0,204,255]},"_msgid":"c93322b.3d7c5e"}

better ?

Yes.

[{"id":"3d6370f2.5997e","type":"inject","z":"64ce1d00.d049e4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":540,"y":580,"wires":[["e0e5a7e.f181b58"]]},{"id":"e0e5a7e.f181b58","type":"function","z":"64ce1d00.d049e4","name":"simulated modbus data","func":"\nreturn {\"topic\":\"cd1d4476.573438\",\"messageId\":\"5fdcba413f27802973d6dffb\",\"payload\":[0,0,1,3501,0,0,0,52479],\"queueLengthByUnitId\":{\"unitId\":3,\"queueLength\":0},\"queueUnitId\":3,\"unitId\":3,\"modbusRequest\":{\"value\":{\"IS\":5.726},\"unitid\":\"3\",\"fc\":4,\"address\":\"31397\",\"quantity\":\"8\",\"messageId\":\"5fdcba413f27802973d6dffb\"},\n\"responseBuffer\":{\"data\":[0,0,1,3501,0,0,0,52479],\n\"buffer\":Buffer.from([0,0,0,0,0,1,13,173,0,0,0,0,0,0,204,255])},\"_msgid\":\"c93322b.3d7c5e\"};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":580,"wires":[["cb154c41.9c237"]]},{"id":"cb154c41.9c237","type":"buffer-parser","z":"64ce1d00.d049e4","name":"using biguint64","data":"responseBuffer.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"biguint64be","name":"item1_64bit","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"biguint64be","name":"item2_64bit","offset":8,"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,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":960,"y":580,"wires":[["cf52ae85.b4a1c"]]},{"id":"cf52ae85.b4a1c","type":"debug","z":"64ce1d00.d049e4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":580,"wires":[]},{"id":"19a445e.c5b09ba","type":"inject","z":"64ce1d00.d049e4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":540,"y":640,"wires":[["12fdf919.2a4cf7"]]},{"id":"12fdf919.2a4cf7","type":"function","z":"64ce1d00.d049e4","name":"simulated modbus data","func":"\nreturn {\"topic\":\"cd1d4476.573438\",\"messageId\":\"5fdcba413f27802973d6dffb\",\"payload\":[0,0,1,3501,0,0,0,52479],\"queueLengthByUnitId\":{\"unitId\":3,\"queueLength\":0},\"queueUnitId\":3,\"unitId\":3,\"modbusRequest\":{\"value\":{\"IS\":5.726},\"unitid\":\"3\",\"fc\":4,\"address\":\"31397\",\"quantity\":\"8\",\"messageId\":\"5fdcba413f27802973d6dffb\"},\n\"responseBuffer\":{\"data\":[0,0,1,3501,0,0,0,52479],\n\"buffer\":Buffer.from([0,0,0,0,0,1,13,173,0,0,0,0,0,0,204,255])},\"_msgid\":\"c93322b.3d7c5e\"};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":640,"wires":[["ad16f77d.357018"]]},{"id":"ad16f77d.357018","type":"buffer-parser","z":"64ce1d00.d049e4","name":"using uint32","data":"responseBuffer.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32be","name":"item1_32bit","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32be","name":"item2_32bit","offset":12,"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,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":950,"y":640,"wires":[["2993872d.c81998"]]},{"id":"2993872d.c81998","type":"debug","z":"64ce1d00.d049e4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":640,"wires":[]},{"id":"e9ef3a7b.bb6f38","type":"inject","z":"64ce1d00.d049e4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":540,"y":700,"wires":[["e66af765.b1ea08"]]},{"id":"e66af765.b1ea08","type":"function","z":"64ce1d00.d049e4","name":"simulated modbus data","func":"\nreturn {\"topic\":\"cd1d4476.573438\",\"messageId\":\"5fdcba413f27802973d6dffb\",\"payload\":[0,0,1,3501,0,0,0,52479],\"queueLengthByUnitId\":{\"unitId\":3,\"queueLength\":0},\"queueUnitId\":3,\"unitId\":3,\"modbusRequest\":{\"value\":{\"IS\":5.726},\"unitid\":\"3\",\"fc\":4,\"address\":\"31397\",\"quantity\":\"8\",\"messageId\":\"5fdcba413f27802973d6dffb\"},\n\"responseBuffer\":{\"data\":[0,0,1,3501,0,0,0,52479],\n\"buffer\":Buffer.from([0,0,0,0,0,1,13,173,0,0,0,0,0,0,204,255])},\"_msgid\":\"c93322b.3d7c5e\"};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":700,"wires":[["7c2868e7.df1b98"]]},{"id":"7c2868e7.df1b98","type":"buffer-parser","z":"64ce1d00.d049e4","name":"using 2xuint32","data":"responseBuffer.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32be","name":"item1a_32bit","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32be","name":"item1b_32bit","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32be","name":"item2a_32bit","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32be","name":"item2b_32bit","offset":12,"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,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":960,"y":700,"wires":[["70549f59.0ec38"]]},{"id":"9dbdb810.6117a8","type":"debug","z":"64ce1d00.d049e4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1130,"y":760,"wires":[]},{"id":"70549f59.0ec38","type":"function","z":"64ce1d00.d049e4","name":"calc 64 bit from 2-32bit vals","func":"var hi1 = msg.payload.item1a_32bit << 32;\nvar lo1 = msg.payload.item1b_32bit;\nvar hi2 = msg.payload.item2a_32bit << 32;\nvar lo2 = msg.payload.item1b_32bit;\nmsg.payload.item1_calculated = hi1 + lo1;\nmsg.payload.item2_calculated = hi2 + lo2;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":760,"wires":[["9dbdb810.6117a8"]]}]

NOTES:

  • V1: just works if you have up-to-date NODEJS version (1st recommendation)
  • V2: If the values are < 32 bit max - you can just use the 32 bit types (but you need to set the offset correctly - as demonstrated)
  • V3: If the values are > 32 bit max BUT ALSO < 2^53 then this work (values over 2^53 will become inaccurate due to JS limitation - that is why bigint was created)
1 Like