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:
<STX(0000967038250000006025000000000000203954764800000040901300000000000000000000000000000000000000000040140464570000)<ETX><HT>
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:
0000967038250000
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