# How to write the string array containing hex commands to serial out node without buffer on node v0.10.40/node-red v0.15.2

**URL:** <https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150>\
**Category:** General\
**Created:** [6 May 2020 03:23 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150 "2020-05-06T03:23:27Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Waled22](https://avatars.discourse-cdn.com/v4/letter/w/13edae/32.png) [@Waled22](https://discourse.nodered.org/u/Waled22)\
**Post date:** [6 May 2020 03:23 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/1 "2020-05-06T03:23:27Z")

</div>

I need to write the string array of hex commands to the serial supported RS232 device, I am trying to send it using a buffer but it is not available in Node-Red version 0.10.40. Could anyone suggest me some possible ways and ideas to send this data? I welcome your suggestions and thank you in advance!

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c0cb7e06e3bc1d824a273f3714251f1381ed3af0.png)

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [6 May 2020 04:36 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/2 "2020-05-06T04:36:28Z")

</div>

There is no "Node-Red version 0.10.40". Do you mean NodeJS? 🤔

If so, that version is pretty outdated and no longer supported by Node-RED.

Which version of Node-RED are you running? You can see it in the console or at the bottom of the editor settings menu.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/4383a18f79439e5a00658609ca88d3e72a0b6470.png)

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [6 May 2020 04:52 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/3 "2020-05-06T04:52:05Z")

</div>

But apart from that, you can use a `function` node to achieve the same.

Have a look at the [Buffer docs](https://nodejs.org/dist/latest-v10.x/docs/api/buffer.html#buffer_class_method_buffer_from_array) and the `Buffer.from()` method to create a Buffer from an array.

As an example:

```auto
msg.payload = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
return msg;

```

---

<div class="post-metadata">

**Author:** ![Waled22](https://avatars.discourse-cdn.com/v4/letter/w/13edae/32.png) [@Waled22](https://discourse.nodered.org/u/Waled22)\
**Post date:** [6 May 2020 14:03 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/4 "2020-05-06T14:03:16Z")

</div>

Thank you for your reply. I admit that I am a beginner but It is strange because in the console the version is 0.15.2

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/998b67104db59fe8e138fe597d76a6b10e50370d.png) , but the node -v command shows 0.10.40.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [6 May 2020 14:04 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/5 "2020-05-06T14:04:41Z")

</div>

> [@Waled22](#):
>
> version is 0.15.2

Oof, that's a pretty old version, ~~especially if you are capable of running Node v10 on this device.~~ Can you explain how you installed node-red, and if it would be possible to upgrade to a newer version?  
Edit: sorry I read that wrong, Node v0.10 is far older. Still the same question, can you explain how you installed it/what platform you're running on?

---

<div class="post-metadata">

**Author:** ![Waled22](https://avatars.discourse-cdn.com/v4/letter/w/13edae/32.png) [@Waled22](https://discourse.nodered.org/u/Waled22)\
**Post date:** [6 May 2020 14:40 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/6 "2020-05-06T14:40:54Z")

</div>

I did not install the node-red by myself, actually; I am working on the wireless gateway device in which the node-red of that version is pre-installed.

---

<div class="post-metadata">

**Author:** ![Waled22](https://avatars.discourse-cdn.com/v4/letter/w/13edae/32.png) [@Waled22](https://discourse.nodered.org/u/Waled22)\
**Post date:** [6 May 2020 14:46 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/7 "2020-05-06T14:46:31Z")

</div>

I tried to implement your idea but this error message came, do you know where have I done something wrong?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/e/2ef9bea09b8d3f240c8dcd0eb9cd0f45f7d8ffab.png)

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [6 May 2020 14:53 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/8 "2020-05-06T14:53:04Z")

</div>

> [@kuema](#):
>
> Have a look at the [Buffer docs](https://nodejs.org/dist/latest-v10.x/docs/api/buffer.html#buffer_class_method_buffer_from_array) and the `Buffer.from()` method to create a Buffer from an array.

Sadly, that won't work, because of this small note:

> [@](#):
>
> Added in: v5.10.0

When running node v0.10 (EOL 2016), you're unable to use the Buffer functionality.  
As is shown with the error displayed:

> [@Waled22](#):
>
> I tried to implement your idea but this error message came, do you know where have I done something wrong?

---

<div class="post-metadata">

**Author:** ![Waled22](https://avatars.discourse-cdn.com/v4/letter/w/13edae/32.png) [@Waled22](https://discourse.nodered.org/u/Waled22)\
**Post date:** [6 May 2020 15:00 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/9 "2020-05-06T15:00:27Z")

</div>

You are right because in the latest version of node-red I got the expected output. Do you have any idea what should I do now to implement same thing in the old version? ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e6d0d278a6d5d5719b69b98eb31bfb69f5ce1070.png),

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [6 May 2020 15:09 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/10 "2020-05-06T15:09:44Z")

</div>

You can go back to the 0.10.x version of the Buffer docs to see the available functions: [https://nodejs.org/docs/latest-v0.10.x/api/buffer.html](https://nodejs.org/docs/latest-v0.10.x/api/buffer.html)

I think the following would do it:

```auto
msg.payload = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
return msg;

```

---

<div class="post-metadata">

**Author:** ![Waled22](https://avatars.discourse-cdn.com/v4/letter/w/13edae/32.png) [@Waled22](https://discourse.nodered.org/u/Waled22)\
**Post date:** [6 May 2020 15:17 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/11 "2020-05-06T15:17:05Z")

</div>

Thank you, I go through the Buffer docs. By the way, your code generated this output  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/5/c5d9edd499d92e3296e1ee8104554a9b55bd1536.png)

---

<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:** [20 May 2020 15:17 UTC](https://discourse.nodered.org/t/how-to-write-the-string-array-containing-hex-commands-to-serial-out-node-without-buffer-on-node-v0-10-40-node-red-v0-15-2/26150/12 "2020-05-20T15:17:08Z")

</div>

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