Node red -> Set / Reset variable

Hi,

sorry I'm too stupid.

can someone please help me?

I get messages over a serial port.

and split them up into bits.

that goes so far.

so now i would like to set the bits if a certain condition is met.

value from the buffer is 63 and the bit is true
set output to 1,
value from the buffer is 63 and bit is false
set output to zero.

[
    {
        "id": "168a0eba.e0c4c9",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "9c8cf84d.c99fe",
        "type": "serial in",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "serial": "594f0a28.3ab69c",
        "x": 230,
        "y": 20,
        "wires": [
            [
                "f0690ab2.8663c",
                "e4f41c35.a18be8"
            ]
        ]
    },
    {
        "id": "e4f41c35.a18be8",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 430,
        "y": 20,
        "wires": []
    },
    {
        "id": "4e57db48.b3532c",
        "type": "bit-sixteen",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "x": 410,
        "y": 560,
        "wires": [
            [
                "5bef9a28.e01c3c"
            ],
            [
                "398f4f2d.84bfd"
            ],
            [
                "b7912265.add86"
            ],
            [
                "a06d28f5.49635"
            ],
            [
                "d6a9395e.483e5"
            ],
            [
                "eb9da86c.b4bf7"
            ],
            [
                "43a587f3.f9cd78"
            ],
            [
                "8ef2c142.deafc8"
            ],
            [],
            [],
            [],
            [],
            [],
            [],
            [],
            []
        ]
    },
    {
        "id": "a06d28f5.49635",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 380,
        "wires": []
    },
    {
        "id": "5bef9a28.e01c3c",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 260,
        "wires": []
    },
    {
        "id": "398f4f2d.84bfd",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 300,
        "wires": []
    },
    {
        "id": "b7912265.add86",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 340,
        "wires": []
    },
    {
        "id": "d6a9395e.483e5",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 420,
        "wires": []
    },
    {
        "id": "eb9da86c.b4bf7",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 460,
        "wires": []
    },
    {
        "id": "43a587f3.f9cd78",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 500,
        "wires": []
    },
    {
        "id": "8ef2c142.deafc8",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 540,
        "wires": []
    },
    {
        "id": "551cfc27.7a88c4",
        "type": "serial out",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "serial": "594f0a28.3ab69c",
        "x": 870,
        "y": 40,
        "wires": []
    },
    {
        "id": "c3fdaae8.2562",
        "type": "inject",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "2",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[\"0x68\",\"0x02\",\"0x02\",\"0x68\",\"0x00\",\"0x02\",\"0x02\",\"0x16\"]",
        "payloadType": "bin",
        "x": 700,
        "y": 120,
        "wires": [
            [
                "551cfc27.7a88c4"
            ]
        ]
    },
    {
        "id": "f0690ab2.8663c",
        "type": "buffer-parser",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "hex",
                "name": "item2",
                "offset": 43,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "swap16",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "",
        "resultType": "value",
        "resultTypeType": "output",
        "multipleResult": true,
        "fanOutMultipleResult": true,
        "setTopic": true,
        "outputs": 1,
        "x": 170,
        "y": 900,
        "wires": [
            [
                "442a76cb.7d5bd8",
                "f21e096.4c39c78"
            ]
        ]
    },
    {
        "id": "442a76cb.7d5bd8",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 550,
        "y": 900,
        "wires": []
    },
    {
        "id": "f21e096.4c39c78",
        "type": "function",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "func": "msg.payload = parseInt(\"0x\"+msg.payload);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 240,
        "y": 760,
        "wires": [
            [
                "d76d4ca2.b29368",
                "4e57db48.b3532c"
            ]
        ]
    },
    {
        "id": "d76d4ca2.b29368",
        "type": "debug",
        "z": "168a0eba.e0c4c9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 570,
        "y": 760,
        "wires": []
    },
    {
        "id": "594f0a28.3ab69c",
        "type": "serial-port",
        "serialport": "/dev/ttyUSB0",
        "serialbaud": "9600",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "waitfor": "",
        "dtr": "none",
        "rts": "none",
        "cts": "none",
        "dsr": "none",
        "newline": "1000",
        "bin": "bin",
        "out": "interbyte",
        "addchar": "",
        "responsetimeout": "1000"
    }
]


many thousand thanks

As we don't have your serial device, can you copy the buffer by clicking the copy button that appears under your mouse cursor when you hover over the debug messages and paste them in a code block so we can simulate your flow?

Also, explain which value and which bit are used for comparison.

Questions...

  • As far as i can see, your serial data is different each time - how can you be certain the value you want is in byte 43 (I got that from the single entry in the buffer parser)

  • What is sending this data (what is the serial device)? Perhaps it has a known protocol ? or perhaps you are in control of the format of data it transmits?

Hello, it's an alarm system.

when the query is sent, the first status information is received.
if you are asked again, the second status information appears.

I once wrote a short summary, hope it is clear.

I hope google translates correctly.
unfortunately my english is not that good

Start ertse abfrage:
Start first query:

Beim Senden von diesen Wert, wird der Status ausgegeben:
When sending this value, the status is output:
\x68\x02\x02\x68\x00\x02\x02\x16

Status 1.)
(Copy from Data msg.payload buffer)

Dieser gibt den status der Alarmanlage:
This gives the status of the alarm system:
[2,104,104,2,2,64,22,66,62,104,104,62,2,115,36,50,5,0,2,0,255,254,247,255,255,255,158,158,158,158,158,158,158,158,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,248,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,86,6,67,33,135,101,255,255,22,55]


Nach erhalt start 2 sofort abfrage:
After receiving start 2 immediately query:


Beim Senden von diesen Wert, wird der Status ausgegeben:
When sending this value, the status is output:
\x68\x02\x02\x68\x00\x02\x02\x16

Status 2.)
(Copy from Data msg.payload buffer)

Dieser zeigt den status der eingänge der alarmanlage:
This shows the status of the inputs of the alarm system:
[2,104,104,2,2,64,22,66,46,104,104,46,2,115,36,34,0,0,1,0,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,251,255,255,255,255,255,255,86,6,67,33,135,101,255,255,22,69]



Wenn keine abfrage aktiv ist, sendet die anlage allle 3 sec:
If no query is active, the system sends every 3 seconds:
\x68\x02\x02\x68\x40\x02\x42\x16



Auswertung der Antworten:
Evaluating the answers:


for example the status:
\x68\x3E\x3E\x68\x73\x02\x32\x24\.\.\.\.\.\.\.\.\.\.\1\.
bit 1 = unscharf   /   blurred
bit 2 = intern scharf   /   internally sharp   
bit 3 = extern scharf   /   externally sharp
bit 4 = Alarm   /   alarm
bit 5 = Störung   /   Disorder
bit 6 = bereit intern scharf   /   ready internally armed
bit 7 = bereit extern scharf   /   ready externally armed
bit 8 = ......



for example the status of inputs digital:   
\x68\x2E\x2E\.\.\.\.\.\.\.\.\.\1\.
bit 1 = Bereich 1
bit 2 = Bereich 2
bit 3 = Bereich 3
bit 4 = .....
bit 5 = .....
........
.....
..



for example the stus of bus inputs:
\x68\x2E\x2E\.\.\.\.\.\.\.\.\.\.\.\.\.\.\1\.
bit 1 = Bus Melder 1
bit 2 = Bus Melder 2
bit 3 = Bus Melder 3
bit 4 = ......
.....
..

my problem is now.

with the first query, the bit "xy" is true

with the second query comes a different status.

then of course there is also the state of the second state.

so the state of bit "xy" always changes from the first state from true to false to true .....

Sorry, no, it is as clear as mud :wink:

So to break this down a little bit.

When you send

[0x68, 0x2, 0x2, 0x68, 0x0, 0x2, 0x2, 0x16]

You get back

[2,104,104,2,2,64,22,66,62,104,104,62,2,115,36,50,5,0,2,0,255,254,247,255,255,255,158,158,158,158,158,158,158,158,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,248,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,86,6,67,33,135,101,255,255,22,55]

Then you send again (the same data)

[0x68, 0x2, 0x2, 0x68, 0x0, 0x2, 0x2, 0x16]

You get a different response?

[2,104,104,2,2,64,22,66,46,104,104,46,2,115,36,34,0,0,1,0,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,251,255,255,255,255,255,255,86,6,67,33,135,101,255,255,22,69]

Suggestion: Have you tried the Serial Request node instead of separate in and out nodes?



what is xy? Which byte & which bit of that byte?

Sorry :flushed: :see_no_evil:

Yes when i send the first
[0x68, 0x2, 0x2, 0x68, 0x0, 0x2, 0x2, 0x16]

Come Back
[2,104,104,2,2,64,22,66,62,104,104,62,2,115,36,50,5,0,2,0,255,254,247,255,255,255,158,158,158,158,158,158,158,158,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,248,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,86,6,67,33,135,101,255,255,22,55]

yes then i send the same data:
[0x68, 0x2, 0x2, 0x68, 0x0, 0x2, 0x2, 0x16]

and the next staus is coming:
[2,104,104,2,2,64,22,66,46,104,104,46,2,115,36,34,0,0,1,0,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,251,255,255,255,255,255,255,86,6,67,33,135,101,255,255,22,69]

When i not send again when the first status is coming, and wait for example 6 sec. so its start again with the first status.

Bit "xy" = Bit 3, is the status from input status on position 43 = input value.....,251,.....
in binär = 251 = 1,1,1,1 1,0,1,1
[2,104,104,2,2,64,22,66,46,104,104,46,2,115,36,34,0,0,1,0,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,251,255,255,255,255,255,255,86,6,67,33,135,101,255,255,22,69]

I'm sorry that I'm stealing your timey :see_no_evil:

So the difference between those 2 replies is

  • length
  • byte 8
    • 1st response byte 8 == 62
    • 2nd response byte 8 == 46

Using that, you can chose to ignore the 1st response by using a switch node or function node. Then pass that to a buffer parser to pick out the individual bit (or bits or whatever)

Be careful when byte swapping, byte43 ends up in byte42

[{"id":"9435e71a.336128","type":"function","z":"604356b6.3a15e8","name":"Status Request \\x68\\x02\\x02\\x68\\x00\\x02\\x02\\x16","func":"msg.topic = \"status\"\nmsg.payload = Buffer.from([0x68, 0x2, 0x2, 0x68, 0x0, 0x2, 0x2, 0x16]);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1690,"y":180,"wires":[["a3a5e127.5df9a"]]},{"id":"d9dd9f56.71e26","type":"inject","z":"604356b6.3a15e8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1455,"y":180,"wires":[["9435e71a.336128"]],"l":false},{"id":"a3a5e127.5df9a","type":"function","z":"604356b6.3a15e8","name":"fake serial reply","func":"msg.payload = Buffer.from([2, 104, 104, 2, 2, 64, 22, 66, 46, 104, 104, 46, 2, 115, 36, 34, 0, 0, 1, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 255, 255, 255, 255, 255, 255, 86, 6, 67, 33, 135, 101, 255, 255, 22, 69]);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1600,"y":240,"wires":[["61e150e0.0f113"]]},{"id":"61e150e0.0f113","type":"function","z":"604356b6.3a15e8","name":"Is a status response? (byte8==46)","func":"var data = msg.payload;\nvar length = data.length\nif (data[8] == 46) {\n    return msg; //pass msg to next node\n}\n\nreturn null; //halt flow of msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1580,"y":340,"wires":[["70198a4a.321044","6d12f568.e6e56c","be0fdc1d.62afb"]]},{"id":"70198a4a.321044","type":"buffer-parser","z":"604356b6.3a15e8","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"bool","name":"bit0","offset":42,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bool","name":"bit1","offset":42,"length":1,"offsetbit":1,"scale":"1","mask":""},{"type":"bool","name":"bit2","offset":42,"length":1,"offsetbit":2,"scale":"1","mask":""},{"type":"bool","name":"bit3","offset":42,"length":1,"offsetbit":3,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"value","resultTypeType":"output","multipleResult":true,"fanOutMultipleResult":true,"setTopic":true,"outputs":4,"x":1830,"y":340,"wires":[["cd99a7bc.f97dc8"],["a3a865ca.e69d78"],["fcc64125.f2a28"],["5cc20c07.fb4cb4"]]},{"id":"6d12f568.e6e56c","type":"buffer-parser","z":"604356b6.3a15e8","name":"16 bools","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"bool","name":"bools","offset":43,"length":16,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"value","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":1820,"y":500,"wires":[["f676851c.aa9458"]]},{"id":"be0fdc1d.62afb","type":"buffer-parser","z":"604356b6.3a15e8","name":"combo","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"bool","name":"bools","offset":42,"length":16,"offsetbit":0,"scale":"1","mask":""},{"type":"8bit","name":"bits_byte42","offset":42,"length":1,"offsetbit":16,"scale":"1","mask":""},{"type":"byte","name":"byte42","offset":42,"length":1,"offsetbit":16,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":1810,"y":560,"wires":[["bd73b2a0.e482a"]]},{"id":"cd99a7bc.f97dc8","type":"debug","z":"604356b6.3a15e8","name":"bit0","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2030,"y":240,"wires":[]},{"id":"a3a865ca.e69d78","type":"debug","z":"604356b6.3a15e8","name":"bit1","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2030,"y":300,"wires":[]},{"id":"fcc64125.f2a28","type":"debug","z":"604356b6.3a15e8","name":"bit2","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2030,"y":360,"wires":[]},{"id":"5cc20c07.fb4cb4","type":"debug","z":"604356b6.3a15e8","name":"bit3","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2030,"y":420,"wires":[]},{"id":"f676851c.aa9458","type":"debug","z":"604356b6.3a15e8","name":"16 bools from byte 43","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2080,"y":500,"wires":[]},{"id":"bd73b2a0.e482a","type":"debug","z":"604356b6.3a15e8","name":"16 bools from byte 43","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2080,"y":560,"wires":[]}]

hey man,

that works perfectly.

I am so grateful to you. :hugs:

in principle, it only evaluates if the comparison is correct.

so i can now adjust the values ​​i want to receive with the comparison.

[
    {
        "id": "63e7febf.23ee58",
        "type": "tab",
        "label": "Flow 9",
        "disabled": false,
        "info": ""
    },
    {
        "id": "9435e71a.336128",
        "type": "function",
        "z": "63e7febf.23ee58",
        "name": "Status Request \\x68\\x02\\x02\\x68\\x00\\x02\\x02\\x16",
        "func": "msg.topic = \"status\"\nmsg.payload = Buffer.from([0x68, 0x2, 0x2, 0x68, 0x0, 0x2, 0x2, 0x16]);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 510,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "d9dd9f56.71e26",
        "type": "inject",
        "z": "63e7febf.23ee58",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 275,
        "y": 120,
        "wires": [
            [
                "9435e71a.336128"
            ]
        ],
        "l": false
    },
    {
        "id": "a3a5e127.5df9a",
        "type": "function",
        "z": "63e7febf.23ee58",
        "name": "fake serial reply",
        "func": "msg.payload = Buffer.from([2, 104, 104, 2, 2, 64, 22, 66, 46, 104, 104, 46, 2, 115, 36, 34, 0, 0, 1, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 255, 255, 255, 255, 255, 255, 86, 6, 67, 33, 135, 101, 255, 255, 22, 69]);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 420,
        "y": 180,
        "wires": [
            []
        ]
    },
    {
        "id": "61e150e0.0f113",
        "type": "function",
        "z": "63e7febf.23ee58",
        "name": "Is a status response? (byte0==62)  Staus der Anlage",
        "func": "var data = msg.payload;\nvar length = data.length\nif (data[0] == 62) {\n    return msg; //pass msg to next node\n}\n\nreturn null; //halt flow of msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 300,
        "y": 320,
        "wires": [
            [
                "6d12f568.e6e56c",
                "be0fdc1d.62afb",
                "70198a4a.321044"
            ]
        ]
    },
    {
        "id": "70198a4a.321044",
        "type": "buffer-parser",
        "z": "63e7febf.23ee58",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "bool",
                "name": "bit0",
                "offset": 42,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "bool",
                "name": "bit1",
                "offset": 42,
                "length": 1,
                "offsetbit": 1,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "bool",
                "name": "bit2",
                "offset": 42,
                "length": 1,
                "offsetbit": 2,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "bool",
                "name": "bit3",
                "offset": 42,
                "length": 1,
                "offsetbit": 3,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "bool",
                "name": "item5",
                "offset": 42,
                "length": 1,
                "offsetbit": 4,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "bool",
                "name": "item6",
                "offset": 42,
                "length": 1,
                "offsetbit": 5,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "bool",
                "name": "item7",
                "offset": 42,
                "length": 1,
                "offsetbit": 6,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "bool",
                "name": "item8",
                "offset": 42,
                "length": 1,
                "offsetbit": 7,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "swap16",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "",
        "resultType": "value",
        "resultTypeType": "output",
        "multipleResult": true,
        "fanOutMultipleResult": true,
        "setTopic": true,
        "outputs": 8,
        "x": 650,
        "y": 280,
        "wires": [
            [
                "cd99a7bc.f97dc8"
            ],
            [
                "a3a865ca.e69d78"
            ],
            [
                "fcc64125.f2a28"
            ],
            [
                "5cc20c07.fb4cb4"
            ],
            [
                "14ede463.841144"
            ],
            [
                "8f168722.e6732"
            ],
            [
                "2b3d94fd.fd6bbc"
            ],
            [
                "6ddaaa8f.fb81c4"
            ]
        ]
    },
    {
        "id": "6d12f568.e6e56c",
        "type": "buffer-parser",
        "z": "63e7febf.23ee58",
        "name": "16 bools",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "bool",
                "name": "bools",
                "offset": 42,
                "length": 16,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "swap16",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "",
        "resultType": "value",
        "resultTypeType": "output",
        "multipleResult": false,
        "fanOutMultipleResult": false,
        "setTopic": true,
        "outputs": 1,
        "x": 620,
        "y": 640,
        "wires": [
            [
                "f676851c.aa9458"
            ]
        ]
    },
    {
        "id": "be0fdc1d.62afb",
        "type": "buffer-parser",
        "z": "63e7febf.23ee58",
        "name": "combo",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "bool",
                "name": "bools",
                "offset": 43,
                "length": 16,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "8bit",
                "name": "bits_byte42",
                "offset": 43,
                "length": 1,
                "offsetbit": 16,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "byte",
                "name": "byte42",
                "offset": 43,
                "length": 1,
                "offsetbit": 16,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "swap16",
        "swap2": "",
        "swap3": "",
        "swap1Type": "swap",
        "swap2Type": "swap",
        "swap3Type": "swap",
        "msgProperty": "payload",
        "msgPropertyType": "",
        "resultType": "keyvalue",
        "resultTypeType": "output",
        "multipleResult": false,
        "fanOutMultipleResult": false,
        "setTopic": true,
        "outputs": 1,
        "x": 610,
        "y": 700,
        "wires": [
            [
                "bd73b2a0.e482a"
            ]
        ]
    },
    {
        "id": "cd99a7bc.f97dc8",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "bit0",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 970,
        "y": 60,
        "wires": []
    },
    {
        "id": "a3a865ca.e69d78",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "bit1",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 970,
        "y": 120,
        "wires": []
    },
    {
        "id": "fcc64125.f2a28",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "bit2",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 970,
        "y": 180,
        "wires": []
    },
    {
        "id": "5cc20c07.fb4cb4",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "bit3",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 970,
        "y": 240,
        "wires": []
    },
    {
        "id": "f676851c.aa9458",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "16 bools from byte 43",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 640,
        "wires": []
    },
    {
        "id": "bd73b2a0.e482a",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "16 bools from byte 43",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 700,
        "wires": []
    },
    {
        "id": "5bacd5b5.cc2a1c",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 340,
        "y": 400,
        "wires": []
    },
    {
        "id": "1b2b8659.7183da",
        "type": "serial in",
        "z": "63e7febf.23ee58",
        "name": "",
        "serial": "594f0a28.3ab69c",
        "x": 190,
        "y": 240,
        "wires": [
            [
                "61e150e0.0f113"
            ]
        ]
    },
    {
        "id": "14ede463.841144",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "bit4",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 970,
        "y": 320,
        "wires": []
    },
    {
        "id": "8f168722.e6732",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "bit5",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 970,
        "y": 380,
        "wires": []
    },
    {
        "id": "2b3d94fd.fd6bbc",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "bit6",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 970,
        "y": 440,
        "wires": []
    },
    {
        "id": "6ddaaa8f.fb81c4",
        "type": "debug",
        "z": "63e7febf.23ee58",
        "name": "bit7",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 970,
        "y": 500,
        "wires": []
    },
    {
        "id": "594f0a28.3ab69c",
        "type": "serial-port",
        "serialport": "/dev/ttyUSB0",
        "serialbaud": "9600",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "waitfor": "",
        "dtr": "none",
        "rts": "none",
        "cts": "none",
        "dsr": "none",
        "newline": "500",
        "bin": "bin",
        "out": "interbyte",
        "addchar": "",
        "responsetimeout": "1000"
    }
]

10000 thanks :kissing_heart:

Hi,

still have a question about serial-out.

at the moment i was using an inject to send a hex command.

how do I get this into a function?

[
    {
        "id": "2fb770af.b67c1",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "48423331.cb980c",
        "type": "inject",
        "z": "2fb770af.b67c1",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[\"0x68\",\"0x02\",\"0x02\",\"0x68\",\"0x00\",\"0x02\",\"0x02\",\"0x16\"]",
        "payloadType": "bin",
        "x": 460,
        "y": 200,
        "wires": [
            [
                "e9fcfbf8.a625a8"
            ]
        ]
    },
    {
        "id": "e9fcfbf8.a625a8",
        "type": "serial out",
        "z": "2fb770af.b67c1",
        "name": "",
        "serial": "594f0a28.3ab69c",
        "x": 650,
        "y": 200,
        "wires": []
    },
    {
        "id": "594f0a28.3ab69c",
        "type": "serial-port",
        "serialport": "/dev/ttyUSB0",
        "serialbaud": "9600",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "waitfor": "",
        "dtr": "none",
        "rts": "none",
        "cts": "none",
        "dsr": "none",
        "newline": "500",
        "bin": "bin",
        "out": "interbyte",
        "addchar": "",
        "responsetimeout": "1000"
    }
]

thx,
mike

This should do it
msg.payload = Buffer.from(["0x68","0x02","0x02","0x68","0x00","0x02","0x02","0x16"])

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.