convert hex to decimal

2,555 views
Skip to first unread message

Henk Smith

unread,
Sep 25, 2015, 10:46:03 AM9/25/15
to Node-RED
Hi. Can anyone advise how I would go about converting a payload containing a series of hex numbers such as 80 C2 0E 5B 28 6F into decimal within node-red

The ideal output after the conversion would be a comma separated array like 128, 194, 14, 91, 40, 111

Thank you

Luis Montes

unread,
Sep 25, 2015, 10:50:41 AM9/25/15
to node...@googlegroups.com
You want a function with something like

msg.payload = msg.payload.split(' ').map(function(hex){ return parseInt(hex, 16); });



--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Henk Smith

unread,
Sep 26, 2015, 4:29:31 AM9/26/15
to Node-RED
Works perfectly! Thank you so much for the assistance. Much appreciated :)
Reply all
Reply to author
Forward
0 new messages