Convert a buffer received via TCP

Hi there,

I am quite new to Node-RED but very excited! Based on this forum I have been able to send a HEX command over TCP to my Husqvarna Automower - and received an answer as a buffer. So far so good. However - now I am stuck at converting the buffer back to a readable string.

The answer from the device is [15,54,189,0,0] and I would like to convert this to a readable string. I have tried a simple 3 step flow for testing this function:

  1. Inject / msg.payload=buffer, content: [15,54,189,0,0]

  2. function:
    msg.payload = msg.payload.toString()
    return msg;

  3. Debug
    ...returns something crazy: "6�"

Any suggestions how to convert the buffer back readable for humans?

Any help is highly appreciated, thank you and best regards, Christian

Hi & welcome to the forum.

It would be far easier to make a small demo flow for someone to import.

What do you think [15,54,189,0,0] should be as a string?

15 = non printable char
54 = "6"
189 = "¢" (for my codepage)
0 = null (C string null terminator)

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