I have a dobot Mg400 with the following code:
And then a simple flow in node red to inject strings using TCP connection (MG400 is the server):
The code is executed as I would expect, robot does commands and I get the reply back (ex. "ScannerIsEmpty!!"), but then dobot studio throws this error:
src0.lua:18: attempt to index a nil value (global 'tcp1')
So why do you post it on the Node Red forum and not in Dobot forum? Because it does not do it when i inject from an app on my phone or the debugging tool in dobot studio, only when done from Node Red. It also does not do it, if i use the TCP out node... but then i wont get a reply and i need that. So what does the TCP request node in Node red do differently to provoke this error?
[
{
"id": "c4396e2906bd2811",
"type": "tab",
"label": "Server",
"disabled": false,
"info": "",
"env": []
},
{
"id": "fa6a975f06c0d443",
"type": "inject",
"z": "c4396e2906bd2811",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "GetFoto",
"payloadType": "str",
"x": 120,
"y": 200,
"wires": [
[
"3710ca17baf02557"
]
]
},
{
"id": "dddbf63d43621b34",
"type": "inject",
"z": "c4396e2906bd2811",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "EmSc",
"payloadType": "str",
"x": 110,
"y": 280,
"wires": [
[
"3710ca17baf02557"
]
]
},
{
"id": "3710ca17baf02557",
"type": "tcp request",
"z": "c4396e2906bd2811",
"name": "",
"server": "192.168.1.6",
"port": "6601",
"out": "time",
"ret": "string",
"splitc": "0",
"newline": "",
"trim": false,
"tls": "",
"x": 400,
"y": 280,
"wires": [
[
"602439f8493fcfd9"
]
]
},
{
"id": "602439f8493fcfd9",
"type": "debug",
"z": "c4396e2906bd2811",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 660,
"y": 280,
"wires": []
}
]