Hi,
I tried to query a U64 Modbus value for the first time. But no matter how I configure the buffer parser, there is always only one error.
What am I missing?
Hi,
I tried to query a U64 Modbus value for the first time. But no matter how I configure the buffer parser, there is always only one error.
What am I missing?
Hi Becker, Hows it going?
in order for someone to help, better make a copy of the message coming out of the Modbus node (set the Debug node to complete message) and paste here using :
... also what value do you expect to get ?
ps. what version of Node are you using ? node -v
there was a discussion regarding bigInt values not being supported below a certain version of node
Works for me...
demo flow...
[{"id":"9f14c6b8.670228","type":"inject","z":"e5137ea5.3fdd9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[0,0,1,35,8,243,128,0,0,0,128,0]","payloadType":"bin","x":1090,"y":60,"wires":[["c2d8080e.081d88"]]},{"id":"c2d8080e.081d88","type":"buffer-parser","z":"e5137ea5.3fdd9","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"bigint64be","name":"bigint64be","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bigint64le","name":"bigint64le","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"biguint64le","name":"buigint64le","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"biguint64be","name":"buigint64be","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,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":1090,"y":100,"wires":[["7376720d.cb23ac"]]},{"id":"7376720d.cb23ac","type":"debug","z":"e5137ea5.3fdd9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":140,"wires":[]}]
if you want us to look further, copy the FULL message as described by @UnborN
Also, to backup @UnborN hinted at, Bigint64 is a feature of node version > v10.4.0 - so what version of node-js are you on?
And lastly, only most recent node-red (v1.2.4+ i think) can display bigint in the debug side-bar
And to add a bit more pain, unless you are actually getting values > int 2,147,483,647 or > uint 4,294,967,295 then I recommend casting the values to regular int/uint as you will have difficulty working with the bigint values once you have them.
v10.16.3
{"topic":"bc57293c.b45d5","messageId":"5fcd1a9b7eae09b6296c0167","payload":[0,0,0,53199,0,0,0,46520],"queueLengthByUnitId":{"unitId":3,"queueLength":0},"queueUnitId":3,"unitId":3,"modbusRequest":{"value":{"T3":28.8},"unitid":"3","fc":4,"address":"31397","quantity":"8","messageId":"5fcd1a9b7eae09b6296c0167"},"responseBuffer":{"data":[0,0,0,53199,0,0,0,46520],"buffer":[0,0,0,0,0,0,207,207,0,0,0,0,0,0,181,184]},"_msgid":"61620b69.6a03b4"}
msg.payload:
[0,0,0,53199,0,0,0,46520]
53199 & 46520 are correct.
but soon it´ll go over 16bit and I need the buffer.
same error
An node version? node-red version? buffer parser version?
EDIT - sorry - I am blind!
Can you capture the FULL message as we pointed out?
I updated to 1.2.6
node-red-contrib-buffer-parser 3.1.3
but ->
"TypeError: Cannot read property 'bind' of undefined"
I did
{"topic":"bc57293c.b45d5","messageId":"5fcd1a9b7eae09b6296c0167","payload":[0,0,0,53199,0,0,0,46520],"queueLengthByUnitId":{"unitId":3,"queueLength":0},"queueUnitId":3,"unitId":3,"modbusRequest":{"value":{"T3":28.8},"unitid":"3","fc":4,"address":"31397","quantity":"8","messageId":"5fcd1a9b7eae09b6296c0167"},"responseBuffer":{"data":[0,0,0,53199,0,0,0,46520],"buffer":[0,0,0,0,0,0,207,207,0,0,0,0,0,0,181,184]},"_msgid":"61620b69.6a03b4"}
I'm having a bad day 2 ticks.
Can you show us what you get from this (its a small flow built from your modbus data...
[{"id":"744c02e3.3e785c","type":"inject","z":"f0c54878.b7be68","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1160,"y":80,"wires":[["61ef089f.2338a8"]]},{"id":"61ef089f.2338a8","type":"function","z":"f0c54878.b7be68","name":"modbus data","func":"\nreturn { \"topic\": \"bc57293c.b45d5\", \n\"messageId\": \"5fcd1a9b7eae09b6296c0167\", \n\"payload\": [0, 0, 0, 53199, 0, 0, 0, 46520], \n\"queueLengthByUnitId\": { \"unitId\": 3, \"queueLength\": 0 }, \n\"queueUnitId\": 3, \"unitId\": 3, \n\"modbusRequest\": { \n \"value\": { \"T3\": 28.8 }, \"unitid\": \"3\", \"fc\": 4, \"address\": \"31397\", \"quantity\": \"8\", \"messageId\": \"5fcd1a9b7eae09b6296c0167\" }, \"responseBuffer\": { \"data\": [0, 0, 0, 53199, 0, 0, 0, 46520],\n \"buffer\": Buffer.from([0, 0, 0, 0, 0, 0, 207, 207, 0, 0, 0, 0, 0, 0, 181, 184]) }, \n\"_msgid\": \"61620b69.6a03b4\" };","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1170,"y":140,"wires":[["b0563f39.60a0d"]]},{"id":"b0563f39.60a0d","type":"buffer-parser","z":"f0c54878.b7be68","name":"","data":"responseBuffer.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"bigint64le","name":"bigint64le","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bigint64be","name":"bigint64be","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,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":1190,"y":200,"wires":[["42c0eecc.55333"]]},{"id":"42c0eecc.55333","type":"debug","z":"f0c54878.b7be68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1220,"y":260,"wires":[]}]
TypeError: Cannot read property 'bind' of undefined
whats wrong with my NR - I see, its working at your NR
the OS is old, 9 (Stretch)
hmmmm
Can you add a catch
and link it to a debug node set to show complete message and paste the content of that msg in a reply please?
catch ? Don´t know how to
[{"id":"87dc0eac.9baeb","type":"catch","z":"f0c54878.b7be68","name":"","scope":null,"uncaught":false,"x":1090,"y":360,"wires":[["62ec60f.62ed9a"]]},{"id":"62ec60f.62ed9a","type":"debug","z":"f0c54878.b7be68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1240,"y":360,"wires":[]}]
In this thread Nick mentions that reading 64bit ints from buffer was added in Node 12
It might be a factor but MDN says otherwise
maybe this ? v12 and v10.20
Not sure what you mean @UnborN
If you select the V10 dropdown on the nodejs docs & look at API for node buffer it does support the bigint functions
got it:
{"topic":"bc57293c.b45d5","messageId":"5fcd1a9b7eae09b6296c0167","payload":[0,0,0,53199,0,0,0,46520],"queueLengthByUnitId":{"unitId":3,"queueLength":0},"queueUnitId":3,"unitId":3,"modbusRequest":{"value":{"T3":28.8},"unitid":"3","fc":4,"address":"31397","quantity":"8","messageId":"5fcd1a9b7eae09b6296c0167"},"responseBuffer":{"data":[0,0,0,53199,0,0,0,46520],"buffer":[0,0,0,0,0,0,207,207,0,0,0,0,0,0,181,184]},"_msgid":"ad050b0c.bb6fb8","originalPayload":[0,0,0,53199,0,0,0,46520],"error":{"message":"TypeError: Cannot read property 'bind' of undefined","source":{"id":"b0563f39.60a0d","type":"buffer-parser","count":1},"stack":"TypeError: Cannot read property 'bind' of undefined\n at dataGetter (/home/pi/.node-red/node_modules/node-red-contrib-buffer-parser/buffer-parser.js:373:49)\n at itemReader (/home/pi/.node-red/node_modules/node-red-contrib-buffer-parser/buffer-parser.js:338:30)\n at parser (/home/pi/.node-red/node_modules/node-red-contrib-buffer-parser/buffer-parser.js:461:25)\n at bufferParserNode._inputCallback (/home/pi/.node-red/node_modules/node-red-contrib-buffer-parser/buffer-parser.js:786:31)\n at hooks.trigger (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:203:26)\n at Object.trigger (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/hooks.js:113:9)\n at bufferParserNode.Node._emitInput (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:195:11)\n at bufferParserNode.Node.emit (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:179:25)\n at bufferParserNode.Node.receive..."}}
Can the old OS (Strech) be to blame?