Serial Data Parser / Decoding

Hi all,

I'm new at node red and spent a lot of time with reading here.
My problem is that I have an arduino sending some data to serial port of my raspberry but I can not decode / show them right.

The arduino is measuring and calulating at some analog ports and the results are written to serial port.
This works with a different Software good for many years.
I want to build a new GUI to show this data in dashboard.

The data which will be written by arduino is a mix from float int and boolean.

//Data to transmit to Raspberry PI3
  State state = {
    .vdc12 = VDC12, //this is float
    .vdc5 = VDC5, //this is float
    .adc12 = ADC12, //this is float
    .pson = PSON, //this boolean
    .fanon = FANON, //this boolean
    .error = errormsg // this is int
  };
Serial.write("STATE:");
  int size = sizeof(State);
  char* st = (char*) malloc(size);
  memcpy(st, &state, size);
  Serial.write(st, size);
  Serial.write("\n");
  free(st);

  Serial.flush();

Com Port is working and I can debug the output and read State: and then of course nothing useful.
I installed contrib-buffer-parser to parse the the serial message.
Configuration seems not to be too complicate but I'm hanging.

I add 7 items with fan enabled and connected them to 7 text nodes I want to show in dashboard.
Item 1 ascii length=6 Offset=0
At the dashboard I can read "State:" so this is ok, great!
Item 2 float(le) length=4 offset=6
Item 3 float(le) length=4 offset=10
...
I can not read any valid data, it should be two voltages with 12V and 5V so numbers should be 12,425 and 5,251 for example.

Any hints how to get my valid results shown?

Hi,

there are 2 ways to do this.

V1 - send JSON data over serial then you will have zero isues converting to usable JS object.

V2 - I help you configure buffer parser (I wrote it)

What direction would you prefer?

For V2 I will need sample data (capture it from a debug message), what the values are meant to be and a copy of your current flow.

Hi Steve,

thanks for your help!
I preffer V2 because I can not change the arduino code, otherwise the old software will stop working.

This i have as Flow:

[
    {
        "id": "484d58c6fda0204f",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "70c288ddb00829f0",
        "type": "serial in",
        "z": "484d58c6fda0204f",
        "name": "ArduinioPort",
        "serial": "e13e4297edea67b8",
        "x": 490,
        "y": 440,
        "wires": [
            [
                "f3075837afc8ecaa",
                "d09df61af789b1bf"
            ]
        ]
    },
    {
        "id": "f3075837afc8ecaa",
        "type": "buffer-parser",
        "z": "484d58c6fda0204f",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "ascii",
                "name": "item1",
                "offset": 0,
                "length": 7,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item2",
                "offset": 7,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item3",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item4",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item5",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item6",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item7",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item8",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item9",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "int16le",
                "name": "item10",
                "offset": 0,
                "length": 2,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item11",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item12",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item13",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "item14",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "bool",
                "name": "item15",
                "offset": 0,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "bool",
                "name": "item16",
                "offset": 0,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "int16le",
                "name": "item17",
                "offset": 0,
                "length": 2,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "resultType": "keyvalue",
        "resultTypeType": "return",
        "multipleResult": true,
        "fanOutMultipleResult": true,
        "setTopic": true,
        "outputs": 17,
        "x": 730,
        "y": 440,
        "wires": [
            [
                "bf613881860aaf1a"
            ],
            [
                "91eefa1028143076"
            ],
            [
                "72e0116ee8825d57"
            ],
            [
                "35605d33d591b35b"
            ],
            [
                "3206eef2438376e7"
            ],
            [
                "32ed571a9719ca26"
            ],
            [
                "e7d656daf2a59cac"
            ],
            [
                "66405361458ad166"
            ],
            [
                "4444c120928448e4"
            ],
            [
                "545d20babe835532"
            ],
            [
                "4b573e4edd1a3d3a"
            ],
            [
                "471a20e59a9d9251"
            ],
            [
                "d225840e0ef1d705"
            ],
            [
                "e521a8c056709bfa"
            ],
            [
                "5c33f5e401997df5"
            ],
            [
                "f2036dc190b0f857"
            ],
            [
                "78110d4e44e217e9"
            ]
        ]
    },
    {
        "id": "bf613881860aaf1a",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 0,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Start",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1030,
        "y": 200,
        "wires": []
    },
    {
        "id": "e7d656daf2a59cac",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 10,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Item 7",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1030,
        "y": 440,
        "wires": []
    },
    {
        "id": "66405361458ad166",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 11,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Item 8",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1030,
        "y": 480,
        "wires": []
    },
    {
        "id": "4444c120928448e4",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 1,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Temperature",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1050,
        "y": 520,
        "wires": []
    },
    {
        "id": "4b573e4edd1a3d3a",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 2,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Voltage 50V",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1050,
        "y": 600,
        "wires": []
    },
    {
        "id": "d225840e0ef1d705",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 3,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Voltage 12V",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1050,
        "y": 680,
        "wires": []
    },
    {
        "id": "e521a8c056709bfa",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 4,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Voltage 5V",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1050,
        "y": 720,
        "wires": []
    },
    {
        "id": "471a20e59a9d9251",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 16,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Item 12",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1040,
        "y": 640,
        "wires": []
    },
    {
        "id": "545d20babe835532",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 12,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Band",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1030,
        "y": 560,
        "wires": []
    },
    {
        "id": "3206eef2438376e7",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 8,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Item 5",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1030,
        "y": 360,
        "wires": []
    },
    {
        "id": "72e0116ee8825d57",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 6,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Item 3",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1030,
        "y": 280,
        "wires": []
    },
    {
        "id": "35605d33d591b35b",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 7,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Item 4",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1030,
        "y": 320,
        "wires": []
    },
    {
        "id": "32ed571a9719ca26",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 9,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Item 6",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1030,
        "y": 400,
        "wires": []
    },
    {
        "id": "5c33f5e401997df5",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 13,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "PS On",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1030,
        "y": 760,
        "wires": []
    },
    {
        "id": "91eefa1028143076",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 5,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Item 2",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1030,
        "y": 240,
        "wires": []
    },
    {
        "id": "78110d4e44e217e9",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 15,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Error Code",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1050,
        "y": 840,
        "wires": []
    },
    {
        "id": "f2036dc190b0f857",
        "type": "ui_text",
        "z": "484d58c6fda0204f",
        "group": "1920b9a01dbfe9cc",
        "order": 14,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Fan On",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 1040,
        "y": 800,
        "wires": []
    },
    {
        "id": "d09df61af789b1bf",
        "type": "debug",
        "z": "484d58c6fda0204f",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 620,
        "wires": []
    },
    {
        "id": "e13e4297edea67b8",
        "type": "serial-port",
        "serialport": "/dev/ttyACM0",
        "serialbaud": "57600",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "waitfor": "",
        "dtr": "none",
        "rts": "none",
        "cts": "none",
        "dsr": "none",
        "newline": "\\n",
        "bin": "bin",
        "out": "char",
        "addchar": "",
        "responsetimeout": "10000"
    },
    {
        "id": "1920b9a01dbfe9cc",
        "type": "ui_group",
        "name": "First Try",
        "tab": "a70e322edb38e88c",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "a70e322edb38e88c",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

And this is from my com port:
29.12.2021, 19:46:46node: d09df61af789b1bfmsg.payload : buffer[62]

[83,84,65,84,85,83,58,43,170,101,53,242,222,123,56,43,170,101,53,242,222,123,56,0,0,0,0,0,0,0,0,0,0,128,127,0,0,194,65,17,0,189,230,130,61,0,0,0,0,205,204,68,65,232,105,160,64,0,0,0,0,10]

Hope you can use it.
In your parser I config all 17 items with the right definition (float/int/bool)

Hi Nero, as you replied to the thread (and didnt reply to my msg) I did not get a notification - so didnt know you had replied.

Any how.

You did include these items but they were definitely not configured correctly. Each item should be length 1 and each offset should be set according to the position of the data in the buffer.


As requested in my 1st reply, can you please provide the sample serial data WITH the expected values.

e.g...

Here is the data...

  • ABCDEF12345ABCDEF12345ABCDEF12345ABCDEF12345

and these were the ACTUAL values at the time of the serial message...

  • Text: STATUS:
  • vdc12 = 12.0123, //this is float
  • vdc5 = 4.9987, //this is float
  • adc12 = 11.90123, //this is float
  • pson = true, //this boolean
  • fanon = false, //this boolean
  • error = 0 // this is int

ALSO...

Your sample comm data doesnt look right. What is the full declaration of the State struct ?

Hi Steve,

as far as I understood on arduino code STATUS: is in ASCII and this I can read at the com port.
Followed by an array with my data inside.
The size of the array is calculated and send as information.
So the message should look like STATUS:ARRAY,SIZE\n
At memcpy status is copied to st and &status means as bit.

Size is used to check at the old software that the message is not broken.

This is the code:

//Data to transmit to Raspberry PI3
  Status status = {
    .poutForwardPeak = Pout_FOR,
    .poutReflectedPeak = Pout_REF,
    .poutForward = Pout_FOR,
    .poutReflected = Pout_REF,
    .vswr = VSWR,
    .adc50c = ADC50C,
    .efficiency = efficiency,
    .temperature = tempsensor,
    .band = band,
    .vdc50 = VDC50,
    .vbias = VBIAS,
    .vdc12 = VDC12,
    .vdc5 = VDC5,
    .pson = pson,
    .fanon = fanon,
    .error = errormsg
  };

  Serial.write("STATUS:");
  int size = sizeof(Status);
  char* st = (char*) malloc(size);
  memcpy(st, &status, size);
  Serial.write(st, size);
  Serial.write("\n");
  free(st);

  Serial.flush();
#ifndef status_h
#define status_h

typedef struct {
  float poutForwardPeak;
  float poutReflectedPeak;
  float poutForward;
  float poutReflected;
  float vswr;
  float adc50c;
  float efficiency;
  float temperature;
  int band;
  float vdc50;
  float vbias;
  float vdc12;
  float vdc5;
  bool pson;
  bool fanon;
  int error;
} Status;

#endif

The software controls the system, without having a connection to the software I will not get good valid information.

ok, that struct is different to the first one - but it still doesn't match the example data you sent.

If you aren't accurate in your information - I cant really help!

Instead, I have knocked up a demo to show you.

I used your (new) Status struct, added some demo data & spit out the decimal values to generate "fake serial" data & setup the buffer parser to show you how it works...

[{"id":"f3075837afc8ecaa","type":"buffer-parser","z":"484d58c6fda0204f","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"ascii","name":"name","offset":0,"length":7,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"poutForwardPeak","offset":7,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item3","offset":11,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item4","offset":15,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item5","offset":19,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item6","offset":23,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item7","offset":27,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"item8","offset":31,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"temperature","offset":35,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int32le","name":"band","offset":39,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"vdc50","offset":43,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"vbias","offset":47,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"vdc12","offset":51,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"vdc5","offset":55,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bool","name":"pson","offset":59,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bool","name":"fanon","offset":60,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":true,"setTopic":true,"outputs":1,"x":1350,"y":220,"wires":[["54d926f325b7f150"]]},{"id":"54d926f325b7f150","type":"debug","z":"484d58c6fda0204f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1390,"y":300,"wires":[]},{"id":"2d04bdd0af29ff2f","type":"inject","z":"484d58c6fda0204f","name":"fake serial data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[83,84,65,84,85,83,58, 205,204,140,63,205,204,12,64,51,51,83,64,205,204,140,64,0,0,176,64,51,51,211,64,102,102,246,64,205,204,12,65,231,3,0,0,82,56,74,66,127,242,118,68,207,247,65,65,207,247,159,64,0,1,0,0,123,0,0,0  ]","payloadType":"bin","x":1240,"y":160,"wires":[["f3075837afc8ecaa"]]}]

I'' leave the other bits for you to fill in / sort out.

Great!
Now it's working, thanks for your help.

Main Problem was the missunderstanding in length and offset.

Cheers
Nero

Hi Steve,

I finished half of the project receiving data from com port and display them in my new gui.
Now I'm thinking about how to transmit data.
Arduino is waiting for the start message MSS: (4Bytes)
followed by number between 0-255 int (8bit)
followed by number between 0-255 int (8bit)
followed by a bool (1byte)
\n should be transmitted by the com port settings.

The data is string like MSS:9656true
This can not be send directly to the comport because it would be all ASCII and not like above.
So I think I should seperate this in:
ASCII 4 Bytes
INT 1 Byte
INT 1 Byte
BOOL 1 Byte
And send this to the com port.

I start with this:

[
    {
        "id": "f763669f.60792",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "364cdf88.ad365",
        "type": "inject",
        "z": "f763669f.60792",
        "name": "Input",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "MSS:9656true",
        "payloadType": "str",
        "x": 610,
        "y": 260,
        "wires": [
            [
                "f281c1bb.4433d8"
            ]
        ]
    },
    {
        "id": "e3fb5662.c8d778",
        "type": "debug",
        "z": "f763669f.60792",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1090,
        "y": 260,
        "wires": []
    },
    {
        "id": "f281c1bb.4433d8",
        "type": "buffer-maker",
        "z": "f763669f.60792",
        "name": "",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "name": "item1",
                "type": "ascii",
                "length": 4,
                "dataType": "msg",
                "data": "payload"
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "x": 830,
        "y": 260,
        "wires": [
            [
                "e3fb5662.c8d778"
            ]
        ]
    }
]

But not sure how to get the number 96 and number 56 each as one number and not two ASCII 9 + ASCII 6.

So try adding them to buffer maker, then feed the output to a debug node and see if it meets your requirements.

Have a look above, exactly what I did.

MSS: I choose ASCII with length of 4
96 is just one numer as INT, choosing int8 or 8Bit with length 1 give me a 0 in output.

IN: MSS:96
Out: [77,83,83,58,0]

Here my flow just for testing.

[
    {
        "id": "f763669f.60792",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "364cdf88.ad365",
        "type": "inject",
        "z": "f763669f.60792",
        "name": "Input",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "MSS:96",
        "payloadType": "str",
        "x": 610,
        "y": 260,
        "wires": [
            [
                "f281c1bb.4433d8"
            ]
        ]
    },
    {
        "id": "e3fb5662.c8d778",
        "type": "debug",
        "z": "f763669f.60792",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1090,
        "y": 260,
        "wires": []
    },
    {
        "id": "f281c1bb.4433d8",
        "type": "buffer-maker",
        "z": "f763669f.60792",
        "name": "",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "name": "item1",
                "type": "ascii",
                "length": 4,
                "dataType": "msg",
                "data": "payload"
            },
            {
                "name": "item2",
                "type": "int8",
                "length": 1,
                "dataType": "msg",
                "data": "payload"
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "x": 830,
        "y": 260,
        "wires": [
            [
                "e3fb5662.c8d778"
            ]
        ]
    }
]

Try this...

[{"id":"364cdf88.ad365","type":"inject","z":"f763669f.60792","name":"Input","props":[{"p":"text","v":"MSS:","vt":"str"},{"p":"byte1","v":"96","vt":"num"},{"p":"byte2","v":"56","vt":"num"},{"p":"byte3","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":1986,"y":80,"wires":[["f281c1bb.4433d8"]]},{"id":"e3fb5662.c8d778","type":"debug","z":"f763669f.60792","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2034,"y":212,"wires":[]},{"id":"f281c1bb.4433d8","type":"buffer-maker","z":"f763669f.60792","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"ascii","length":4,"dataType":"msg","data":"text"},{"name":"item2","type":"int8","length":1,"dataType":"msg","data":"byte1"},{"name":"item3","type":"int8","length":1,"dataType":"msg","data":"byte2"},{"name":"item4","type":"int8","length":1,"dataType":"msg","data":"byte3"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":2022,"y":144,"wires":[["e3fb5662.c8d778"]]}]

image

Yes this works.
In my case I do have a simple string inside a datapoint of VIS.
MSS:9656true
So as I understood right I've to findout how I can prepare my string to fit your sample inject.

What I can do on datapoint side is reformat the valaue of the datapoint in:
["MSS:",56,56,0]

Steve, I don't give up!

Now I have may DP seperated in 4 DP.
DP1 = MSS: as string
DP2 = 96 as number
DP2 = 56 as number
DP2 = true as boolean

The Topic of each DP is the DP Name in IOB.

Is it possible to point them all to Buffer Maker and work with the msg.topic?
Idea is like that:

[
    {
        "id": "8684153f.9fd16",
        "type": "buffer-maker",
        "z": "f6be1ceb.99b5a",
        "name": "",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "name": "item1",
                "type": "ascii",
                "length": 4,
                "dataType": "msg",
                "data": "topic.DP1"
            },
            {
                "name": "item2",
                "type": "byte",
                "length": 1,
                "dataType": "msg",
                "data": "topic.DP2"
            },
            {
                "name": "item3",
                "type": "byte",
                "length": 1,
                "dataType": "msg",
                "data": "topic.DP3"
            },
            {
                "name": "item4",
                "type": "bool",
                "length": 1,
                "dataType": "msg",
                "data": "topic.DP4"
            }
        ],
        "swap1": "",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "str",
        "x": 790,
        "y": 460,
        "wires": [
            []
        ]
    }
]


I tried with **msg.**topic.0_userdata.0.MSG but did not work for me.
Or is it the wrong way?

msg.topic should really only ever be a string - use msg.something_else_or_whatever (e.g. msg.payload)

So you want to parse this string MSS:9656true into a buffer of...

  • string (4 char)
  • byte (number)
  • byte (number)
  • byte (bool)

Here is 2 different working examples. It converts the array format you posted and the string format...

wGGokNAN3b

[{"id":"8684153f.9fd16","type":"buffer-maker","z":"a55f8f0f93e84992","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"string","length":4,"dataType":"msg","data":"payload.prefix"},{"name":"item2","type":"byte","length":1,"dataType":"msg","data":"payload.byte1"},{"name":"item3","type":"byte","length":1,"dataType":"msg","data":"payload.byte2"},{"name":"item4","type":"byte","length":1,"dataType":"msg","data":"payload.bool"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":1210,"y":760,"wires":[["46517ffff2f6ee08"]]},{"id":"67597d65a863dc36","type":"inject","z":"a55f8f0f93e84992","name":"[\"MSS:\",96,56,1]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"MSS:\",96,56,1]","payloadType":"json","x":820,"y":620,"wires":[["d96948f15a51b50d"]]},{"id":"766e62a33fda189d","type":"inject","z":"a55f8f0f93e84992","name":"MSS:9646true","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"MSS:9656true","payloadType":"str","x":810,"y":760,"wires":[["2b7f577bdf66780c"]]},{"id":"2b7f577bdf66780c","type":"function","z":"a55f8f0f93e84992","name":"break down string","func":"\nvar data = msg.payload;\nvar prefix = data.substr(0,4);\nvar byte1 = parseInt(data.substr(4,2));\nvar byte2 = parseInt(data.substr(6,2));\nvar flag = data.substr(8);\nvar bool = flag\nif (bool == \"true\") {\n    bool = 1;\n} else {\n    bool = 0;\n}\n\nmsg.payload = {\n    prefix,\n    byte1,\n    byte2,\n    flag,\n    bool,\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1010,"y":760,"wires":[["8684153f.9fd16","18d76a4d0035dea4"]]},{"id":"46517ffff2f6ee08","type":"debug","z":"a55f8f0f93e84992","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1390,"y":760,"wires":[]},{"id":"18d76a4d0035dea4","type":"debug","z":"a55f8f0f93e84992","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1010,"y":800,"wires":[]},{"id":"31d50976b2596ad9","type":"inject","z":"a55f8f0f93e84992","name":"MSS:1234false","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"MSS:1234false","payloadType":"str","x":820,"y":720,"wires":[["2b7f577bdf66780c"]]},{"id":"d96948f15a51b50d","type":"buffer-maker","z":"a55f8f0f93e84992","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"string","length":4,"dataType":"msg","data":"payload[0]"},{"name":"item2","type":"byte","length":1,"dataType":"msg","data":"payload[1]"},{"name":"item3","type":"byte","length":1,"dataType":"msg","data":"payload[2]"},{"name":"item4","type":"byte","length":1,"dataType":"msg","data":"payload[3]"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":1210,"y":620,"wires":[["f025e2de41133207"]]},{"id":"785f85c9146bf384","type":"inject","z":"a55f8f0f93e84992","name":"[\"MSS:\",12,34,0]","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"MSS:\",12,34,0]","payloadType":"json","x":820,"y":580,"wires":[["d96948f15a51b50d"]]},{"id":"f025e2de41133207","type":"debug","z":"a55f8f0f93e84992","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1390,"y":620,"wires":[]},{"id":"850675dba89bf5bb","type":"comment","z":"a55f8f0f93e84992","name":"Array of data items","info":"","x":810,"y":540,"wires":[]},{"id":"a474799e09525545","type":"comment","z":"a55f8f0f93e84992","name":"String of data","info":"","x":790,"y":680,"wires":[]}]

Steve this is great!
I use the array, the string method is also nice but the numbers can be 1, 2 or 3 long.
In this case I must add 0 or 00 in front auf my number, with array I've no problems
with that.

So the msg.payload looks fine.

I recognize that there is a difference between sending an ASCII string like HELLO direct to serial port and sending the same string to buffermaker and then to serial port.
Difference is that in case 1 the \n is added automatic and messege is send.
In case 2 I've to remove the automatic \n in serial port config but than the message seems not to be send.
Is it possible that I've todo somthing that the buffer is send to the serial poert, not just pressing inject button?

show me a screenshot of your serial node config

If I remove \n no type error anymore but my other strings wont be send anymore withot \n
Also the buffer seems not to be send, I see the output in debug but not on the other side of serial

The section above where you highlighted. It's set to wait for a \n. Change it to operate after a short time (eg 300ms)

And remove the append \n

As written above:

If I remove \n no type error anymore but my other strings wont be send anymore without \n

Also the buffer seems not to be send, I see the output in debug but not on the other side of serial.