# Buffer parser specyfication from msg

**URL:** <https://discourse.nodered.org/t/buffer-parser-specyfication-from-msg/51962>\
**Category:** General\
**Created:** [7 October 2021 10:08 UTC](https://discourse.nodered.org/t/buffer-parser-specyfication-from-msg/51962 "2021-10-07T10:08:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ketpa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ketpa/32/42496_2.png) [@ketpa](https://discourse.nodered.org/u/ketpa)\
**Post date:** [7 October 2021 10:08 UTC](https://discourse.nodered.org/t/buffer-parser-specyfication-from-msg/51962/1 "2021-10-07T10:08:50Z")

</div>

I try use buffer parser with specyfications from msg.settings  
Specyfications are the same, but values not

```auto
[{"id":"30016563.f4d772","type":"function","z":"15ff44a1.77852b","name":"","func":"var o={\n options: {\n byteSwap: \"array[0]\",\n resultType: \"keyvalue\",\n singleResult: true,\n setTopic: true,\n msgProperty: \"payload\"\n },\n items: [\n {\n name: \"item1\",\n type: \"int16le\",\n offset: 0,\n length: 6,\n offsetbit: 0,\n scale: \"1\",\n mask: \"\"\n \n }\n]\n};\n \n \n \n\nmsg.settings = o;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":2840,"wires":[["7ece758.8c71f0c"]]},{"id":"940b5942.11b698","type":"debug","z":"15ff44a1.77852b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":2840,"wires":[]},{"id":"27926104.a41fa6","type":"inject","z":"15ff44a1.77852b","name":"trz data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"rwSvBLAEsASwBLAEsQSwBLAEsASwBLAEsASwBLAEsASwBLAEsQSxBLEEsQSxBLIEsgSyBLIEsgSyBLIEsgSyBLIEsgSyBLIEsgSyBLIEswSzBLMEswSyBLIEsgSyBLIEsgSyBLIEswSzBLMEswSzBLMEswSzBLMEswSzBLMEswSzBLMEswS0BLMEswSzBLMEswSzBLMEswSzBLMEswSzBLMEtAS0BLQEtAS0BLQEtAS0BLQEtAS0BLQEtASzBLMEswSzBLMEtASzBLQEtASzBLMEswSzBLMEswS0BLQEswSzBLMEswSzBLMEswSzBLME","payloadType":"str","x":90,"y":2840,"wires":[["a240b6f6.f7e4b","a8310d58.bdb57"]]},{"id":"a240b6f6.f7e4b","type":"base64","z":"15ff44a1.77852b","name":"","action":"","property":"payload","x":220,"y":2840,"wires":[["30016563.f4d772"]]},{"id":"7ece758.8c71f0c","type":"buffer-parser","z":"15ff44a1.77852b","name":"","data":"payload","dataType":"msg","specification":"settings","specificationType":"msg","items":[{"type":"int16le","name":"item1","offset":0,"length":7,"offsetbit":0,"scale":"1","mask":""},{"type":"int16le","name":"item2","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"array","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":510,"y":2840,"wires":[["940b5942.11b698"]]},{"id":"a8310d58.bdb57","type":"base64","z":"15ff44a1.77852b","name":"","action":"","property":"payload","x":220,"y":2900,"wires":[["1ca4861f.fba142"]]},{"id":"1ca4861f.fba142","type":"buffer-parser","z":"15ff44a1.77852b","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16le","name":"item1","offset":0,"length":6,"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":370,"y":2900,"wires":[["27bd74f9.add134"]]},{"id":"27bd74f9.add134","type":"debug","z":"15ff44a1.77852b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":2900,"wires":[]}]

```

 ![obraz](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1a2006e9e0782f260143b95bff5c8f1c99116478.png)

---

<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:** [7 October 2021 11:06 UTC](https://discourse.nodered.org/t/buffer-parser-specyfication-from-msg/51962/2 "2021-10-07T11:06:12Z")

</div>

You had an odd value in `byteSwap` - it looks like you copied the value from a working nodes `msg.specification` output on the sidebar but **DIDNT** use the **"Copy Value"** button because you had set `byteSwap` to a string of `array[0]` instead of a zero length array `[]`

In short, always use "Copy Value" button...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/3/a3a855e9d7285ea3d3e819bb203bb66ec7fb7ebb.png)

Look at the function code - I left your original `var o` in so you can see the difference.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/cae05d59c32b0f39934acdf1975e9634a1ff49d2.png)

```auto
[{"id":"30016563.f4d772","type":"function","z":"bc3ceb40.260568","name":"","func":"var o={\n options: {\n byteSwap: \"array[0]\",\n resultType: \"keyvalue\",\n singleResult: true,\n setTopic: true,\n msgProperty: \"payload\"\n },\n items: [\n {\n name: \"item1\",\n type: \"int16le\",\n offset: 0,\n length: 6,\n offsetbit: 0,\n scale: \"1\",\n mask: \"\"\n \n }\n]\n};\nvar o2 = { \n \"options\": { \n \"byteSwap\": [], \n \"resultType\": \"keyvalue\", \n \"singleResult\": true, \n \"msgProperty\": \"payload\", \n \"setTopic\": true \n }, \n \"items\": [\n { \n \"type\": \"int16le\", \n \"name\": \"item1\", \n \"offset\": 0, \n \"length\": 6, \n \"offsetbit\": 0, \n \"scale\": \"1\", \n \"mask\": \"\", \n \"id\": 0, \n }\n] \n}\n \n \n\nmsg.settings = o2;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1540,"y":160,"wires":[["7ece758.8c71f0c"]]},{"id":"940b5942.11b698","type":"debug","z":"bc3ceb40.260568","name":"via msg.settings","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1880,"y":160,"wires":[]},{"id":"27926104.a41fa6","type":"inject","z":"bc3ceb40.260568","name":"trz data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"rwSvBLAEsASwBLAEsQSwBLAEsASwBLAEsASwBLAEsASwBLAEsQSxBLEEsQSxBLIEsgSyBLIEsgSyBLIEsgSyBLIEsgSyBLIEsgSyBLIEswSzBLMEswSyBLIEsgSyBLIEsgSyBLIEswSzBLMEswSzBLMEswSzBLMEswSzBLMEswSzBLMEswS0BLMEswSzBLMEswSzBLMEswSzBLMEswSzBLMEtAS0BLQEtAS0BLQEtAS0BLQEtAS0BLQEtASzBLMEswSzBLMEtASzBLQEtASzBLMEswSzBLMEswS0BLQEswSzBLMEswSzBLMEswSzBLME","payloadType":"str","x":1150,"y":160,"wires":[["8f1d24e471f3c0dd","1db8e718718240f8"]]},{"id":"7ece758.8c71f0c","type":"buffer-parser","z":"bc3ceb40.260568","name":"","data":"payload","dataType":"msg","specification":"settings","specificationType":"msg","items":[{"type":"int16le","name":"item1","offset":0,"length":7,"offsetbit":0,"scale":"1","mask":""},{"type":"int16le","name":"item2","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"array","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":1690,"y":160,"wires":[["940b5942.11b698"]]},{"id":"1ca4861f.fba142","type":"buffer-parser","z":"bc3ceb40.260568","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16le","name":"item1","offset":0,"length":6,"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":1550,"y":220,"wires":[["27bd74f9.add134"]]},{"id":"27bd74f9.add134","type":"debug","z":"bc3ceb40.260568","name":"pre-set in editor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1880,"y":220,"wires":[]},{"id":"8f1d24e471f3c0dd","type":"function","z":"bc3ceb40.260568","name":"base64-->buffer","func":"msg.payload = Buffer.from(msg.payload, \"base64\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1360,"y":160,"wires":[["30016563.f4d772"]]},{"id":"1db8e718718240f8","type":"function","z":"bc3ceb40.260568","name":"base64-->buffer","func":"msg.payload = Buffer.from(msg.payload, \"base64\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1360,"y":220,"wires":[["1ca4861f.fba142"]]}]

```

---

<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:** [21 October 2021 11:06 UTC](https://discourse.nodered.org/t/buffer-parser-specyfication-from-msg/51962/3 "2021-10-21T11:06:53Z")

</div>

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