Buffer parser specyfication from msg

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

[{"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":[]}]

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

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

[{"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"]]}]
2 Likes

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