# Convert a buffer received via TCP

**URL:** <https://discourse.nodered.org/t/convert-a-buffer-received-via-tcp/58390>\
**Category:** General\
**Created:** [15 February 2022 13:54 UTC](https://discourse.nodered.org/t/convert-a-buffer-received-via-tcp/58390 "2022-02-15T13:54:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChristianLoacker](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christianloacker/32/56499_2.png) [@ChristianLoacker](https://discourse.nodered.org/u/ChristianLoacker)\
**Post date:** [15 February 2022 13:54 UTC](https://discourse.nodered.org/t/convert-a-buffer-received-via-tcp/58390/1 "2022-02-15T13:54:50Z")

</div>

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

---

<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 February 2022 14:23 UTC](https://discourse.nodered.org/t/convert-a-buffer-received-via-tcp/58390/2 "2022-02-15T14:23:58Z")

</div>

Hi & welcome to the forum.

> [@ChristianLoacker](#):
>
> I have tried a simple 3 step flow for testing this function

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

> [@ChristianLoacker](#):
>
> Any suggestions how to convert the buffer back readable for humans?

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)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 April 2022 14:24 UTC](https://discourse.nodered.org/t/convert-a-buffer-received-via-tcp/58390/3 "2022-04-16T14:24:09Z")

</div>

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