# Need help on reverse hex

**URL:** <https://discourse.nodered.org/t/need-help-on-reverse-hex/48445>\
**Category:** General\
**Created:** [15 July 2021 08:40 UTC](https://discourse.nodered.org/t/need-help-on-reverse-hex/48445 "2021-07-15T08:40:13Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [15 July 2021 12:25 UTC](https://discourse.nodered.org/t/need-help-on-reverse-hex/48445/4 "2021-07-15T12:25:16Z")

</div>

Here is a version with a pre-processor function "Reverse Digits"

![kk8vhvzcrM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/8/4853684e679be94cc56df1a9d4bbab31289cdcf0.gif)

```auto
[{"id":"48710450b1015ae2","type":"buffer-parser","z":"f9687f620c582b41","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"hex","name":"hex","offset":0,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","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":1290,"y":1980,"wires":[["be3855e7e3db7224"]]},{"id":"c01496387b913dbd","type":"inject","z":"f9687f620c582b41","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":1175,"y":1860,"wires":[["93a9fe50e7dce0f6"]],"l":false},{"id":"93a9fe50e7dce0f6","type":"function","z":"f9687f620c582b41","name":"[0xe011, 0x9111, 0x32a, 0x100]","func":"msg.payload = [0xe011, 0x9111, 0x32a, 0x100]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1350,"y":1860,"wires":[["12016d8462cdf276"]]},{"id":"be3855e7e3db7224","type":"debug","z":"f9687f620c582b41","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1450,"y":1980,"wires":[]},{"id":"12016d8462cdf276","type":"function","z":"f9687f620c582b41","name":"Reverse digits in 16bit data array","func":"let data = msg.payload;\n\nmsg.payload = data.map(e => {\n let n1 = (e & 0xf000) >> 12\n let n2 = (e & 0x0f00) >> 4\n let n3 = (e & 0x00f0) << 4\n let n4 = (e & 0x000f) << 12\n return n1 | n2 | n3 | n4;\n})\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1360,"y":1920,"wires":[["48710450b1015ae2"]]},{"id":"57f54b59b6350372","type":"inject","z":"f9687f620c582b41","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":1175,"y":1820,"wires":[["f0b8995005a4403e"]],"l":false},{"id":"f0b8995005a4403e","type":"function","z":"f9687f620c582b41","name":"[0x4321, 0x8765, 0xcba9, 0x0fed]","func":"msg.payload = [0x4321, 0x8765, 0xcba9, 0x0fed]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1360,"y":1820,"wires":[["12016d8462cdf276"]]}]

```

---

_[View the full topic](https://discourse.nodered.org/t/need-help-on-reverse-hex/48445)._
