# Send Buffer over usb Serial Node

**URL:** <https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494>\
**Category:** General\
**Created:** [9 October 2019 08:38 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494 "2019-10-09T08:38:52Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evian](https://avatars.discourse-cdn.com/v4/letter/e/5e9695/32.png) [@Evian](https://discourse.nodered.org/u/Evian)\
**Post date:** [9 October 2019 08:38 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/1 "2019-10-09T08:38:52Z")

</div>

Im trying to send a Buffer over the Serial Node.  
When injecting said buffer my debug window says folowing:  
TypeError [ERR\_INVALID\_ARG\_TYPE]: The "list[1]" argument must be one of type Array, Buffer, or Uint8Array. Received type string

Now that error message is very strange to me cause im sending a Buffer via Inject node. So its kinda Node Red made. Also when Debugging the Buffer it shows correctly:  
[249,163,19,5,8,0,142,249,249,163,19,5,8, ... ,249]

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

If tried to scan the variable of the buffer in a function with "typeof msg.payload" it brings me back "object" wich isnt a Buffer. After that i tried to convert the object to an array cause the serial node would understand that two right. Nope, well it sends the array but when you look at the Terminal on the other side it looks like this:  
[249,163,19,5,8,0,142,249,249,163,19,5,8, ... ,249]false  
and it should only send the actual bytes, but here it sends everything from the Array.

! TLDR !: i need a way to send a buffer to serial node.

This is what i used:

```auto
[{"id":"521ff28a.a08cac","type":"serial out","z":"91c3f483.866738","name":"Serial_OUT","serial":"4d588bfc.a481f4","x":648,"y":587,"wires":[]},{"id":"a4001877.167a78","type":"inject","z":"91c3f483.866738","name":"Buffer","topic":"","payload":"[\"0xF9\",\"0xA3\",\"0x13\",\"0x05\",\"0x08\",\"0x00\",\"0x8E\",\"0xF9\",\"0xF9\",\"0xA3\",\"0x13\",\"0x05\",\"0x08\",\"0x01\",\"0x1F\",\"0xF9\",\"0xF9\",\"0xA3\",\"0x13\",\"0x05\",\"0x08\",\"0x02\",\"0x6D\",\"0xF9\",\"0xF9\",\"0xA3\",\"0x13\",\"0x05\",\"0x08\",\"0x03\",\"0xFC\",\"0xF9\",\"0xF9\",\"0xA3\",\"0x13\",\"0x05\",\"0x08\",\"0x04\",\"0x89\",\"0xF9\",\"0xF9\",\"0xA3\",\"0x13\",\"0x05\",\"0x08\",\"0x05\",\"0x18\",\"0xF9\",\"0xF9\",\"0xA3\",\"0x13\",\"0x05\",\"0x08\",\"0x06\",\"0x6A\",\"0xF9\",\"0xF9\",\"0xA3\",\"0x13\",\"0x05\",\"0x08\",\"0x07\",\"0xFB\",\"0xF9\"]","payloadType":"bin","repeat":"","crontab":"","once":false,"onceDelay":"","x":261,"y":587,"wires":[["521ff28a.a08cac","232b0fab.4611d"]]},{"id":"232b0fab.4611d","type":"debug","z":"91c3f483.866738","name":"Show Buffer","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":650,"y":639,"wires":[]},{"id":"4d588bfc.a481f4","type":"serial-port","z":"","serialport":"/dev/ttyUSB2","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"200","bin":"bin","out":"time","addchar":"false","responsetimeout":""}]

```

---

<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:** [9 October 2019 09:25 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/2 "2019-10-09T09:25:13Z")

</div>

Hi, please format your flow using the code button or put it between backticks...

`````  
`code`  
`````

Otherwise it is unusable and people won't be able to help you.

---

<div class="post-metadata">

**Author:** ![Evian](https://avatars.discourse-cdn.com/v4/letter/e/5e9695/32.png) [@Evian](https://discourse.nodered.org/u/Evian)\
**Post date:** [9 October 2019 09:29 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/3 "2019-10-09T09:29:44Z")

</div>

I edited it, i believe now its the way you ment it. Thx 😀

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [9 October 2019 10:25 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/4 "2019-10-09T10:25:45Z")

</div>

That flow looks good to me.  
(PS Buffer is a type of object so yes it is an object - you need Buffer.isBuffer(foo) to test if it really is a buffer 🙂  
Which version of node.js, Node-RED and serialport node are you using ?

---

<div class="post-metadata">

**Author:** ![Evian](https://avatars.discourse-cdn.com/v4/letter/e/5e9695/32.png) [@Evian](https://discourse.nodered.org/u/Evian)\
**Post date:** [9 October 2019 10:35 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/5 "2019-10-09T10:35:17Z")

</div>

Well when pressing the Menu icon to the upper right it shows v1.0.1  
But i i thought it was a Version problem two so i ran this [script](https://nodered.org/docs/getting-started/raspberrypi) on my pi.

---

<div class="post-metadata">

**Author:** ![Evian](https://avatars.discourse-cdn.com/v4/letter/e/5e9695/32.png) [@Evian](https://discourse.nodered.org/u/Evian)\
**Post date:** [9 October 2019 14:51 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/6 "2019-10-09T14:51:11Z")

</div>

For everyone having this problem!

1. Try redownloading Node red with this [script](https://nodered.org/docs/getting-started/raspberrypi) it might already solve youre problem.
2. If not you might have to set up youre raspberry pi again from scratch. This step is quite time consuming so you might not wana do it if youre not shure theres no other way cause im certanly not an expert.

---

<div class="post-metadata">

**Author:** ![Mling](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@Mling](https://discourse.nodered.org/u/Mling)\
**Post date:** [27 November 2019 11:45 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/7 "2019-11-27T11:45:25Z")

</div>

I met with the same problem after upgrading node-red. After hours of reinstall node-red, finally find the root cause. Some how the Serial port setting: "Add character to output messages" get a value of "false" in it. This value caused the problem. Remove the value and leave it blank solved the it.

---

<div class="post-metadata">

**Author:** ![Orgjvr](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@Orgjvr](https://discourse.nodered.org/u/Orgjvr)\
**Post date:** [1 December 2019 10:07 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/8 "2019-12-01T10:07:41Z")

</div>

Thanks Mling. This solves my issue as well.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [1 December 2019 17:57 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/9 "2019-12-01T17:57:29Z")

</div>

Thanks for mentioning - pushed a fix so shouldn't happen again.

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [7 December 2019 22:22 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/10 "2019-12-07T22:22:27Z")

</div>

Yes!! This solved my issue! Great and thank you. I didn't want to believe that I have to reinstall node-red again :-/

It would make sense, that Evian marks the correct solution 🙂

---

<div class="post-metadata">

**Author:** ![Evian](https://avatars.discourse-cdn.com/v4/letter/e/5e9695/32.png) [@Evian](https://discourse.nodered.org/u/Evian)\
**Post date:** [10 December 2019 10:16 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/11 "2019-12-10T10:16:04Z")

</div>

THX todaly forgot about this thing so i never thought about any of this. But for the future if ever you need to install Node-Red or update it this could help you. Its a script that does everything automaticaly for you.

---

<div class="post-metadata">

**Author:** ![yfhzs](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@yfhzs](https://discourse.nodered.org/u/yfhzs)\
**Post date:** [21 March 2021 09:19 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/12 "2021-03-21T09:19:15Z")

</div>

Hello, Evian. I have the same problem. I finally solved the problem after reading your post. thank you

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [21 March 2021 16:47 UTC](https://discourse.nodered.org/t/send-buffer-over-usb-serial-node/16494/13 "2021-03-21T16:47:24Z")

</div>


