Send Buffer over usb Serial Node

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

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:

[{"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":""}]

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.

1 Like

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

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 :slight_smile:
Which version of node.js, Node-RED and serialport node are you using ?

1 Like

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 on my pi.

For everyone having this problem!

  1. Try redownloading Node red with this script 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.