Send Array with serial out

Hello everyone
I'm trying to send a buffer or array, created in a function-block, with the serial-out-block.
The problem now is, that the array is sent within the message.payload information. So the array-information are sourounded with "[", array-elements are separeted with ",". But i need only the "raw-array-informations" in uint8.

In the picture you can see the data transmitted by node-red and recorded with an analyzer. Note the "[", the "," and that the array-elements are transmitted in ascii.

(only allowed two insert to pics, sorry)

Serial out:


[{"id":"e02fb919.30ccb8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"98cb9d7a.3815d","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"15","bin":"bin","out":"time","addchar":"","responsetimeout":"10000"},{"id":"1c06d1e8.bdb2c6","type":"serial out","z":"e02fb919.30ccb8","name":"","serial":"98cb9d7a.3815d","x":680,"y":280,"wires":[]},{"id":"946d00db.4cdfa8","type":"function","z":"e02fb919.30ccb8","name":"Telegramm","func":"var telegramm= {};\n\n/* raw array*/\nvar data = new Array([\n    0x55,\n    0x0f,\n    3,\n    255,\n    244,\n    57,\n    126,\n    159,\n    0,\n    0x20,\n    0x40,\n    0x00,\n    0x00,\n    0x00,\n    0x00,\n    0xff,\n    ]);\n\n/* calculate the Checksum */\nvar uint8 = new Uint8Array(1);\nfor(i = 0; i < 15; i++)\n{\n    uint8[0] += data[0][i];\n}\nuint8[0] = (uint8[0] ^ 0xff ) + 1;\ndata[0][15] = uint8[0];\ntelegramm.payload = data;\n\nreturn telegramm;\n","outputs":1,"noerr":0,"x":480,"y":280,"wires":[["1c06d1e8.bdb2c6","c4fd038a.a2672"]]},{"id":"45696429.06fa04","type":"inject","z":"e02fb919.30ccb8","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":280,"wires":[["946d00db.4cdfa8"]]},{"id":"c4fd038a.a2672","type":"debug","z":"e02fb919.30ccb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":340,"wires":[]},{"id":"275a69d.97b2896","type":"serial in","z":"e02fb919.30ccb8","name":"","serial":"98cb9d7a.3815d","x":220,"y":120,"wires":[["f163fcee.7d88d8"]]},{"id":"f163fcee.7d88d8","type":"debug","z":"e02fb919.30ccb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":440,"y":120,"wires":[]}]

Thank you for your support.

So you are building an array of ints and trying to send them as raw bytes over a serial line?
I think that will work IF you convert the array into a buffer, somthing like this (untested):

var telegramm= {};
/* raw array*/
var data = [
... etc ...

telegramm.payload = Buffer.from(data);
return telegramm;

Two slight issues -- by create a new empty object telegramm you will lose any other fields from the incoming msg object (which may not be a problem in this flow). Also, the use of new Array([...]) has been deprecated in the Javascript language (or at least it seems to be not preferred), so you can just define your data in between square brackets to create the initial data array.

Thank you for your solution
This is my first time with javascript, so its really helpful to learn the do's and don'ts in javascript.
I implemented your code and it works just fine.
A first version to continue developing the code was like this:

msg.payload = new Buffer([data[0][0], data[0][1], data[0][2], data[0][3], data[0][4], data[0][5], data[0][6], data[0][7], data[0][8], data[0][9], data[0][10], data[0][11], data[0][12], data[0][13], data[0][14], data[0][15]]);

But shure, this was a poor, no scalable solution.