Newbie at work:
In my function node this works:
msg.payload = Buffer.from('-v.?\r')
return msg;
Passing the string from my injection node (as in the flow), it does not work:
msg.payload = Buffer.from(msg.payload)
return msg;
I have tried various variations , but did not find out why.
What am i doing wrong?
Thanks
My flow:
[
{
"id": "7ef9dfab0cff67ba",
"type": "tab",
"label": "TCP REQUEST",
"disabled": false,
"info": "",
"env": []
},
{
"id": "cbcde23642237613",
"type": "tcp request",
"z": "7ef9dfab0cff67ba",
"server": "192.168.20.40",
"port": "50001",
"out": "time",
"ret": "buffer",
"splitc": "1000",
"name": "",
"x": 510,
"y": 200,
"wires": [
[
"c4e9b6d3e5e0ad19",
"6026b84bc8dc2e79"
]
]
},
{
"id": "647d2e0b14640b05",
"type": "debug",
"z": "7ef9dfab0cff67ba",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 890,
"y": 240,
"wires": []
},
{
"id": "522e649cb030ad01",
"type": "function",
"z": "7ef9dfab0cff67ba",
"name": "",
"func": "msg.payload = Buffer.from(msg.payload)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 260,
"y": 240,
"wires": [
[
"cbcde23642237613"
]
]
},
{
"id": "c4e9b6d3e5e0ad19",
"type": "function",
"z": "7ef9dfab0cff67ba",
"name": "",
"func": "msg.payload = msg.payload.toString().split('.');\nmsg.payload[0];\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 720,
"y": 240,
"wires": [
[
"647d2e0b14640b05"
]
]
},
{
"id": "baf28b66599c876c",
"type": "inject",
"z": "7ef9dfab0cff67ba",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "-p.?\\r",
"payloadType": "str",
"x": 80,
"y": 240,
"wires": [
[
"522e649cb030ad01"
]
]
},
{
"id": "6026b84bc8dc2e79",
"type": "debug",
"z": "7ef9dfab0cff67ba",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 890,
"y": 140,
"wires": []
}
]