Convert 20-byte string to 10-number array

I am pulling a specific 20-byte set of data from the SNMP node. Every 2 bytes represent a different number. I need the output to be an array of 10 numbers, which will be sent to the InfluxDB node.

SNMP gives me an array[1], with the data I need in object 0 labeled:
type: 0x4 value: "????????" and tstr: "OctetString"
What I need is in value, so I split it and move the payload.value to payload.

I've tried multiple things from this point, and none have worked. Closest I get is the binary-node, setting the pattern to b16 => label, b16 => label2, x128. This gives me an object with { label: 65021, label2: 65021}. The resulting numbers should only be 3 digits, and not the same.

I also tried the buffer-parser node. This seems exactly what I want: the type, a label, set length, offset before the next one. However, I get a RangeError for attempting to write outside buffer bounds.

Any thoughts on what I'm doing wrong, or a better way to do it from the start? I did not think this was going to be the difficult part of my project! Thanks in advance.

Can you give us a example flow with data?

use buffer parser...

Demo flow...

[{"id":"33b1b208.fa2e1e","type":"inject","z":"4b3f21a3.ba434","name":"fake SNMP 20 byte buffer","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[0,11,0,22,0,33,0,44,0,55,0,66,0,77,0,88,0,99,0,111]","payloadType":"bin","x":1990,"y":1860,"wires":[["c827dfeb.cb932","6bcc0ffc.5d21f"]]},{"id":"c827dfeb.cb932","type":"buffer-parser","z":"4b3f21a3.ba434","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item2","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item3","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item4","offset":6,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item5","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item6","offset":10,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item7","offset":12,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item8","offset":14,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item9","offset":16,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item10","offset":18,"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":1950,"y":1920,"wires":[["e60792c2.2721d"]]},{"id":"e60792c2.2721d","type":"debug","z":"4b3f21a3.ba434","name":"after","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2190,"y":1920,"wires":[]},{"id":"6bcc0ffc.5d21f","type":"debug","z":"4b3f21a3.ba434","name":"before","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2190,"y":1860,"wires":[]}]

Thanks for the quick responses. This is my first time exporting a flow, so I hope I got the formatting correct.

This flow shows the 4 results I described and am able to get. I must be missing a conversion somewhere to get rid of the "??????".

Using the buffer parser node from Steve-Mcl's example results in the same out of bounds error.

[{"id":"ff6977af.56c1f8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"4322b239.2c8d1c","type":"snmp","z":"ff6977af.56c1f8","host":"192.168.1.100","community":"public","version":"2c","oids":"1.3.6.1.4.1.26565.1.1.6.6.0","timeout":5,"name":"","x":260,"y":180,"wires":[["62bc9db6.0dd7e4","d5a497a9.9d7eb8"]]},{"id":"62bc9db6.0dd7e4","type":"split","z":"ff6977af.56c1f8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":430,"y":240,"wires":[["26aad779.fdb598","44abee0b.12ddb"]]},{"id":"26aad779.fdb598","type":"change","z":"ff6977af.56c1f8","name":"","rules":[{"t":"move","p":"payload.value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":300,"wires":[["e7ef94ed.d95c18","96327080.14dda"]]},{"id":"d5a497a9.9d7eb8","type":"debug","z":"ff6977af.56c1f8","name":"snmp payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":510,"y":180,"wires":[]},{"id":"44abee0b.12ddb","type":"debug","z":"ff6977af.56c1f8","name":"post-split payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":240,"wires":[]},{"id":"e7ef94ed.d95c18","type":"debug","z":"ff6977af.56c1f8","name":"post-move payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":300,"wires":[]},{"id":"a18cd3e2.0addf","type":"inject","z":"ff6977af.56c1f8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":80,"y":100,"wires":[["4322b239.2c8d1c"]]},{"id":"96327080.14dda","type":"buffer-parser","z":"ff6977af.56c1f8","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"item1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item2","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item3","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item4","offset":6,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item5","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item6","offset":10,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item7","offset":12,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item8","offset":14,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item9","offset":16,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"item10","offset":18,"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":890,"y":360,"wires":[["8157d9a5.a74dd8"]]},{"id":"8157d9a5.a74dd8","type":"debug","z":"ff6977af.56c1f8","name":"post-buffer","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1100,"y":360,"wires":[]}]

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