Problems converting String to Buffer

I have problems converting String to Buffer array.
I receive a TCP (in string mode) with this hexadecimal values "7e f4 0d 00 02 f9 ce f8 5d 14 00 00 7e".
If I config TCP to "stream of Buffer" or "Single Buffer" I can't make the TCP connection. Only works using "stream of Strings"

When I try to convert the TCP string to a Buffer, this add extra values to array and change others.
"7E EF BF BD 0D 00 02 EF BF BD EF BF BD EF BF BD 5D 14 00 00 7E"

I using this command to make the conversion:

var b = Buffer(msg.payload, 16);

How can I convert correctly the input string to byte array or buffer?
Or How can I get a TCP buffer directly??


Hi guys.
Finaly I solved the problem.
I configure the TCP with "Stream of Base64 String" output, and next, I use the next funciction to decode to Buffer:
var data = msg.payload;
var buff = new Buffer(data, 'base64');

Now, I receive the payload correctly.

1 Like