Reverse/split bytes

Hi, I’m loving Node red and learning how to manipulate messages! I have a question which I’m sure someone will find simple!

What’s the best way to reverse/spilt a string and return some data. For example, I have a meter which is sending power values (array buffer) which I’m converting to ASCII string, this is the output:


How to I split everything in the brackets into 16 byte chunks, then split into two byte words, take each byte and reverse the words.

So taking the first 16 byte chunk:


00 00 96 70 38 25 00 00

00 00 25 38 70 69 00 00

= 253871

I want the message to print out like this:

kWh Import: 253,871 Kwh
kWh Export: 0 Kwh
kvarh Q1: 487,654 Kvarh
kvarh Q2: 14 kvarh
kvarh Q3: 0 kvarh
kvarh Q4: 0 kvarh
kVAh: 576,404 kVAh

Maybe following excellent node can do the job for you:


The buffer parser that @janvda had suggested can seem a bit daunting with all the flexibility it provides but there are examples built in (node-red menu, import, examples, node-red-contrib-buffer-parser).

If you get stuck, give me a shout.

1 Like

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