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":""}]
1 Like

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.

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.

5 Likes

Thanks Mling. This solves my issue as well.

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

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 :slight_smile:

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.

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