# Using push into a for loop

**URL:** <https://discourse.nodered.org/t/using-push-into-a-for-loop/42799>\
**Category:** Industrial\
**Created:** [18 March 2021 08:50 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799 "2021-03-18T08:50:42Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoba](https://avatars.discourse-cdn.com/v4/letter/y/57b2e6/32.png) [@yoba](https://discourse.nodered.org/u/yoba)\
**Post date:** [18 March 2021 08:50 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/1 "2021-03-18T08:50:43Z")

</div>

Hi there,

I'm trying to push values from modbus into an array. The values are encoded i floating format. I managed to convert bytes (4) into single floating 😅  
The "function" node returns all this values into an array if I push them one by one:

```auto
[{"id":"b2559ff0.bd2228","type":"modbus-read","z":"4f90fdb9.b07554","name":"","topic":"","showStatusActivities":true,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"HoldingRegister","adr":"121","quantity":"6","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"badbc08.08534c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":190,"y":180,"wires":[[],["ab597b10.1d0db8"]]},{"id":"ab597b10.1d0db8","type":"function","z":"4f90fdb9.b07554","name":"","func":"const buf = Buffer.from(msg.payload.buffer);\nbuf.swap16();\n\nvar my_list, i;\nconst len = (msg.payload.buffer.length);\nmy_list = [];\n\n// push values 1 by 1 in array\nmy_list.push(buf.readFloatLE(0));\nmy_list.push(buf.readFloatLE(4));\nmy_list.push(buf.readFloatLE(8));\n\n// push values in for loop\n//for (i=0; i<=len; i=+ 4){\n// my_list.push(buf.readFloatLE(i));\n//}\n\nmsg.payload = my_list;\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":80,"wires":[["fdbbcc26.59d768"]]},{"id":"fdbbcc26.59d768","type":"debug","z":"4f90fdb9.b07554","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":710,"y":80,"wires":[]},{"id":"badbc08.08534c","type":"modbus-client","z":"","name":"KACO","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"192.168.200.111","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectTimeout":"2000"}]
]

```

It wouldn't be a problem if there were just few values. But I have plenty of registers. To make my code more efficient, I need to push all this values into an array **inside** a for loop (ref. the commented lines in the code above), but when I run this part of code, Node-Red crashes every time.  
Some help would be appreciated 🙂

Regards,

Yoba

---

<div class="post-metadata">

**Author:** ![Simon01011](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@Simon01011](https://discourse.nodered.org/u/Simon01011)\
**Post date:** [18 March 2021 09:06 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/2 "2021-03-18T09:06:11Z")

</div>

Maybe its the  
`i<=len`  
that should be  
`i<len`  
?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 March 2021 09:13 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/3 "2021-03-18T09:13:47Z")

</div>

Have a look at node-red-contrib-buffer-parser. Whilst it may not do exactly what you are asking for (or may, I am not sure) it may be that it would be useful for you.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [18 March 2021 09:19 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/4 "2021-03-18T09:19:30Z")

</div>

wrong syntax

```auto
for (i=0; i<=len; i=+ 4){

```

correct syntax

```auto
for (i=0; i<=len; i += 4){

```

---

<div class="post-metadata">

**Author:** ![yoba](https://avatars.discourse-cdn.com/v4/letter/y/57b2e6/32.png) [@yoba](https://discourse.nodered.org/u/yoba)\
**Post date:** [18 March 2021 09:28 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/5 "2021-03-18T09:28:37Z")

</div>

Thank you @hotNipi for your quick answer 🙂

---

<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:** [18 March 2021 09:36 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/6 "2021-03-18T09:36:13Z")

</div>

@yoba as @Colin suggested, buffer parser takes all the pain out of making sense of your data.

e.g...

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

Demo flow...

```auto
[{"id":"ab597b10.1d0db8","type":"function","z":"5bd4aa78.31d114","name":"","func":"const buf = Buffer.from(msg.payload.buffer);\nbuf.swap16();\n\nvar my_list, i;\nconst len = (msg.payload.buffer.length);\nmy_list = [];\n\n// push values 1 by 1 in array\nmy_list.push(buf.readFloatLE(0));\nmy_list.push(buf.readFloatLE(4));\nmy_list.push(buf.readFloatLE(8));\n\n// // push values in for loop\n// for (i=0; i<len; i=+ 4){\n// my_list.push(buf.readFloatLE(i));\n// }\n\nmsg.payload = my_list;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":924,"y":96,"wires":[["fdbbcc26.59d768"]]},{"id":"fdbbcc26.59d768","type":"debug","z":"5bd4aa78.31d114","name":"Function","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1100,"y":96,"wires":[]},{"id":"cb3e7a56.719758","type":"inject","z":"5bd4aa78.31d114","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":623,"y":192,"wires":[["ed6c26a7.0bfb08"]],"l":false},{"id":"ed6c26a7.0bfb08","type":"function","z":"5bd4aa78.31d114","name":"Fake Modbus","func":"msg.payload = {\n buffer : Buffer.from([0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8])\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":192,"wires":[["25617943.c50d26"]]},{"id":"25617943.c50d26","type":"buffer-parser","z":"5bd4aa78.31d114","name":"","data":"payload.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item2","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item3","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":934,"y":192,"wires":[["b1fec79a.da4a78"]]},{"id":"b1fec79a.da4a78","type":"debug","z":"5bd4aa78.31d114","name":"Parser","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1090,"y":192,"wires":[]},{"id":"c2aee09b.5ac13","type":"inject","z":"5bd4aa78.31d114","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":623,"y":96,"wires":[["567c6031.02666"]],"l":false},{"id":"567c6031.02666","type":"function","z":"5bd4aa78.31d114","name":"Fake Modbus","func":"msg.payload = {\n buffer : Buffer.from([0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8])\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":96,"wires":[["ab597b10.1d0db8"]]},{"id":"97782186.7c8bf","type":"inject","z":"5bd4aa78.31d114","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":623,"y":464,"wires":[["c8767342.8d7d3"]],"l":false},{"id":"c8767342.8d7d3","type":"function","z":"5bd4aa78.31d114","name":"Fake Modbus 3 floats","func":"msg.payload = {\n buffer : Buffer.from([0,1,0,2,0,3,0,4,0,5,0,6])\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":464,"wires":[["102a549f.38297b"]]},{"id":"102a549f.38297b","type":"buffer-parser","z":"5bd4aa78.31d114","name":"","data":"payload.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"item1","offset":0,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":934,"y":464,"wires":[["b365ecd6.bfe85"]]},{"id":"b365ecd6.bfe85","type":"debug","z":"5bd4aa78.31d114","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1110,"y":464,"wires":[]},{"id":"ed450c73.8a799","type":"inject","z":"5bd4aa78.31d114","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":623,"y":512,"wires":[["d0aa6936.981118"]],"l":false},{"id":"d0aa6936.981118","type":"function","z":"5bd4aa78.31d114","name":"Fake Modbus 5 floats","func":"msg.payload = {\n buffer : Buffer.from([0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10])\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":512,"wires":[["102a549f.38297b"]]},{"id":"11dd3da7.31a7f2","type":"comment","z":"5bd4aa78.31d114","name":"Dynamic length","info":"","x":656,"y":432,"wires":[]},{"id":"73e2049d.d0ac6c","type":"inject","z":"5bd4aa78.31d114","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":623,"y":304,"wires":[["f7146e75.96401"]],"l":false},{"id":"f7146e75.96401","type":"function","z":"5bd4aa78.31d114","name":"Fake Modbus","func":"msg.payload = {\n buffer : Buffer.from([0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8])\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":304,"wires":[["4b1fe3a0.88767c"]]},{"id":"4b1fe3a0.88767c","type":"buffer-parser","z":"5bd4aa78.31d114","name":"","data":"payload.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"item1","offset":0,"length":3,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":934,"y":304,"wires":[["6dff71a4.7b454"]]},{"id":"6dff71a4.7b454","type":"debug","z":"5bd4aa78.31d114","name":"Parser","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1090,"y":304,"wires":[]},{"id":"c04113cd.82e42","type":"comment","z":"5bd4aa78.31d114","name":"As a fixed length array","info":"","x":676,"y":272,"wires":[]},{"id":"4c462fe4.cd887","type":"comment","z":"5bd4aa78.31d114","name":"As 3 items (buffer parser)","info":"","x":686,"y":160,"wires":[]},{"id":"34e9a1cf.4082ee","type":"comment","z":"5bd4aa78.31d114","name":"As 3 items (original)","info":"","x":666,"y":64,"wires":[]},{"id":"e7cd2782.f17988","type":"inject","z":"5bd4aa78.31d114","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":639,"y":800,"wires":[["a8479ff8.65711"]],"l":false},{"id":"a8479ff8.65711","type":"function","z":"5bd4aa78.31d114","name":"Fake Modbus","func":"msg.payload = {\n buffer : Buffer.from([0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8])\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":736,"y":800,"wires":[["489df60e.e63538"]]},{"id":"489df60e.e63538","type":"buffer-parser","z":"5bd4aa78.31d114","name":"","data":"payload.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"voltage","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"current","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"freq","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","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":800,"wires":[["852c70cc.67a61"]]},{"id":"852c70cc.67a61","type":"debug","z":"5bd4aa78.31d114","name":"Parser","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1106,"y":800,"wires":[]},{"id":"3cb3e1e2.c74fce","type":"comment","z":"5bd4aa78.31d114","name":"As named items in an object","info":"","x":712,"y":768,"wires":[]},{"id":"cfcbc82e.a1b488","type":"inject","z":"5bd4aa78.31d114","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":639,"y":944,"wires":[["7481222b.c1f99c"]],"l":false},{"id":"7481222b.c1f99c","type":"function","z":"5bd4aa78.31d114","name":"Fake Modbus","func":"msg.payload = {\n buffer : Buffer.from([0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8])\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":736,"y":944,"wires":[["454201fc.cc2a8"]]},{"id":"454201fc.cc2a8","type":"buffer-parser","z":"5bd4aa78.31d114","name":"","data":"payload.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"voltage","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"current","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"freq","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":true,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":950,"y":944,"wires":[["d393f9c4.cdf1c8"]]},{"id":"d393f9c4.cdf1c8","type":"debug","z":"5bd4aa78.31d114","name":"Parser","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1106,"y":944,"wires":[]},{"id":"785aa1dd.9dcad","type":"comment","z":"5bd4aa78.31d114","name":"As individual named items ","info":"","x":702,"y":912,"wires":[]},{"id":"6cab2d8c.6957a4","type":"inject","z":"5bd4aa78.31d114","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":639,"y":1216,"wires":[["ca7502dc.43e59"]],"l":false},{"id":"ca7502dc.43e59","type":"function","z":"5bd4aa78.31d114","name":"Fake Modbus","func":"msg.payload = {\n buffer : Buffer.from([0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8])\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":736,"y":1216,"wires":[["d05a32ed.38439"]]},{"id":"d05a32ed.38439","type":"buffer-parser","z":"5bd4aa78.31d114","name":"","data":"payload.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"voltage","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"current","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"freq","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":true,"fanOutMultipleResult":true,"setTopic":true,"outputs":3,"x":950,"y":1216,"wires":[["3af61c42.774c84"],["5ac54fd0.f5baa"],["b31006a2.ad4f58"]]},{"id":"3af61c42.774c84","type":"debug","z":"5bd4aa78.31d114","name":"float 1","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1106,"y":1184,"wires":[]},{"id":"8bd1cac3.6f5098","type":"comment","z":"5bd4aa78.31d114","name":"As individual items fanned out","info":"","x":712,"y":1184,"wires":[]},{"id":"5ac54fd0.f5baa","type":"debug","z":"5bd4aa78.31d114","name":"float 1","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1106,"y":1216,"wires":[]},{"id":"b31006a2.ad4f58","type":"debug","z":"5bd4aa78.31d114","name":"float 1","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1106,"y":1248,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![yoba](https://avatars.discourse-cdn.com/v4/letter/y/57b2e6/32.png) [@yoba](https://discourse.nodered.org/u/yoba)\
**Post date:** [18 March 2021 09:53 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/7 "2021-03-18T09:53:44Z")

</div>

Hi @Steve-Mcl ,

I took a look at the buffer parser as @Colin suggested. It's exactly what I need. The only problem is I use IoT2040 from Siemens, and I tried to install it without any success. I wonder if the problem is coming from the Debian used. It's a Yocto Rocko.  
Do you have any other suggestion of OS to use on IoT2040?

I really appreciate all the good and quick answers. This forum rocks !!!

---

<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:** [18 March 2021 09:56 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/8 "2021-03-18T09:56:05Z")

</div>

> [@yoba](#):
>
> IoT2040 from Siemens,

Ah, that old chestnut. An overpriced out of date piece of hardware!

The reason is likely the node version on that unit is obsolete.

The solution is: replace it with a £35 raspberry pi 😉

---

<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:** [18 March 2021 09:58 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/9 "2021-03-18T09:58:11Z")

</div>

Mind you, that said, i am certain it still installs - just dont try to use BigInt64

What error do you get?

EDIT:  
Are you using custom firmware on the IoT2040 ?

What node version is installed?

from a terminal, enter `node -v`

Also, what node-red version are you on?

---

<div class="post-metadata">

**Author:** ![yoba](https://avatars.discourse-cdn.com/v4/letter/y/57b2e6/32.png) [@yoba](https://discourse.nodered.org/u/yoba)\
**Post date:** [18 March 2021 13:00 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/10 "2021-03-18T13:00:04Z")

</div>

Hi again,

Sorry for the late answer. I was busy trying to install new image (v2.6.1) from Siemens. Cause I was not sure which version was running on SD card. I used this time npm commands from the terminal and installed buffer parser inside folder _ **.node-red** _  
To answer your question, the versions are:  
root@iot2000:~# node -v  
v8.16.0  
root@iot2000:~# npm -v  
6.4.1

Are they the latest versions?

---

<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:** [18 March 2021 13:04 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/11 "2021-03-18T13:04:50Z")

</div>

> [@yoba](#):
>
> Are they the latest versions?

No where near. Node 8's _End of Life_ is December 31, 2019

[https://nodejs.org/en/about/releases/](https://nodejs.org/en/about/releases/)

But I think buffer-parser will install on V8

Try and if it fails, show me the error(s)

PS: dont forget to tell me NODE-RED version. (its on the node-red menu)

---

<div class="post-metadata">

**Author:** ![yoba](https://avatars.discourse-cdn.com/v4/letter/y/57b2e6/32.png) [@yoba](https://discourse.nodered.org/u/yoba)\
**Post date:** [18 March 2021 13:10 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/12 "2021-03-18T13:10:29Z")

</div>

Node-RED version (from menu): v0.20.7

---

<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:** [18 March 2021 13:13 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/13 "2021-03-18T13:13:07Z")

</div>

wow - yeah - that wont work either.

I do believe you can update node-red to very latest V1.2.9 (even on node v8)

`npm install -g --unsafe-perm node-red`

---

<div class="post-metadata">

**Author:** ![yoba](https://avatars.discourse-cdn.com/v4/letter/y/57b2e6/32.png) [@yoba](https://discourse.nodered.org/u/yoba)\
**Post date:** [18 March 2021 17:52 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/14 "2021-03-18T17:52:57Z")

</div>

Hello!

I struggled to upgrade this IoT2000, but I managed to get this result:  
_18 Mar 15:24:28 - [info] Node-RED version: v1.2.9_  
_18 Mar 15:24:28 - [info] Node.js version: v8.16.0_  
_18 Mar 15:24:28 - [info] Linux 4.4.185-cip35 ia32 LE_

So now I have buffer parser into Node Red as you recommended, but I get error:  
_Error: data is not an array or a buffer_

```auto
[{"id":"67a1ac1.d025d54","type":"buffer-parser","z":"ea67c445.9798f8","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"item1","offset":0,"length":4,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"object","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":430,"y":280,"wires":[["fbd9cc4a.104be"]]}]

```

I've tried different properties, but it didn't help. Could you please tell me how to convert msg.payload (array of integers) into individual topic/payload messages. It's for sending MQTT 🙂

---

<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:** [18 March 2021 20:32 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/15 "2021-03-18T20:32:50Z")

</div>

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

Also, check out the actual working demo i posted...

> [@Steve-Mcl](#):
>
> Demo flow...
> 
> ```auto
> [{"id":"ab597b10.1d0db8","type":"function","z":"5bd4aa78.31d114","name":"","func":"co
> 
> ```

---

<div class="post-metadata">

**Author:** ![yoba](https://avatars.discourse-cdn.com/v4/letter/y/57b2e6/32.png) [@yoba](https://discourse.nodered.org/u/yoba)\
**Post date:** [19 March 2021 08:04 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/16 "2021-03-19T08:04:50Z")

</div>

Hi @Steve-Mcl ,

Thank you for your quick answer. I appreciate a lot.  
I didn't know that the property (as you circled) could be changed. I set it to msg.payload. **buffer**  
Now everthing seems to work properly 👌

Bonus question: could it be possible to put your sample code into the node contrib?  
[https://flows.nodered.org/node/node-red-contrib-buffer-parser](https://flows.nodered.org/node/node-red-contrib-buffer-parser)  
This one was way better than the two presented

Have a nice week-end

---

<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:** [19 March 2021 08:07 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/17 "2021-03-19T08:07:32Z")

</div>

> [@yoba](#):
>
> Bonus question: could it be possible to put your sample code into the node contrib?  
> [node-red-contrib-buffer-parser (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-buffer-parser)  
> This one was way better than the two presented

I will consider it 😛

---

<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:** [2 April 2021 08:08 UTC](https://discourse.nodered.org/t/using-push-into-a-for-loop/42799/18 "2021-04-02T08:08:12Z")

</div>

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