I am collecting NMEA data from an UDP connection and would like to retrieve only some of the NMEA sentences, parse them and write them in a log file.
I have figured all out, but how to stop taking additional sentences when I have already collected all the ones I need.
Below the flow I made (please forgive me if it is not well designed but I am not an expert)
[
{
"id": "e030ac7d47753673",
"type": "switch",
"z": "f989436d61b86384",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "RMC",
"vt": "str"
},
{
"t": "cont",
"v": "MWV",
"vt": "str"
},
{
"t": "cont",
"v": "VWVLW",
"vt": "str"
},
{
"t": "cont",
"v": "DPT",
"vt": "str"
},
{
"t": "cont",
"v": "Fuel#0",
"vt": "str"
},
{
"t": "cont",
"v": "Fuel#1",
"vt": "str"
},
{
"t": "cont",
"v": "EngineHrs",
"vt": "str"
},
{
"t": "cont",
"v": "EngineOil",
"vt": "str"
},
{
"t": "cont",
"v": "RPM",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 9,
"x": 590,
"y": 360,
"wires": [
[
"468b75d4974a0ca7"
],
[
"468b75d4974a0ca7"
],
[
"4e6214c5310a114e"
],
[
"dee70c5c7a681dd8"
],
[
"4230bfb7d2f6e25f"
],
[
"97200db0524d123f"
],
[
"045dff36dd85d182"
],
[
"5c1c6e39f53396c0"
],
[
"51d90f26156dc3a5"
]
]
},
{
"id": "468b75d4974a0ca7",
"type": "nmea",
"z": "f989436d61b86384",
"name": "",
"property": "payload",
"outputProperty": "payload",
"x": 770,
"y": 240,
"wires": [
[
"69eeeb9504fed840"
]
]
},
{
"id": "dee70c5c7a681dd8",
"type": "function",
"z": "f989436d61b86384",
"name": "depth",
"func": "var data = msg.payload.split(\",\");\nmsg.payload = { \"depth\": +data [1] }\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 770,
"y": 320,
"wires": [
[
"69eeeb9504fed840"
]
]
},
{
"id": "4230bfb7d2f6e25f",
"type": "function",
"z": "f989436d61b86384",
"name": "fuel#0",
"func": "var data = msg.payload.split(\",\");\nmsg.payload = { \"tank0\": +data [2] }\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 770,
"y": 360,
"wires": [
[
"69eeeb9504fed840"
]
]
},
{
"id": "97200db0524d123f",
"type": "function",
"z": "f989436d61b86384",
"name": "fuel#1",
"func": "var data = msg.payload.split(\",\");\nmsg.payload = { \"tank1\": +data [2] }\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 770,
"y": 400,
"wires": [
[
"69eeeb9504fed840"
]
]
},
{
"id": "4e6214c5310a114e",
"type": "function",
"z": "f989436d61b86384",
"name": "miles",
"func": "var data = msg.payload.split(\",\");\nmsg.payload = { \"miles\": +data [1] }\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 770,
"y": 280,
"wires": [
[
"69eeeb9504fed840"
]
]
},
{
"id": "045dff36dd85d182",
"type": "function",
"z": "f989436d61b86384",
"name": "enginehrs",
"func": "var data = msg.payload.split(\",\");\nmsg.payload = { \"enginehrs\": +data [2] }\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 780,
"y": 440,
"wires": [
[
"69eeeb9504fed840"
]
]
},
{
"id": "5c1c6e39f53396c0",
"type": "function",
"z": "f989436d61b86384",
"name": "enginedata",
"func": "var data = msg.payload.split(\",\");\nmsg.payload = { \"oilpress\": +data[2], \"watertemp\": +data[6], \"voltage\": +data[10] }\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 790,
"y": 480,
"wires": [
[
"69eeeb9504fed840"
]
]
},
{
"id": "69eeeb9504fed840",
"type": "join",
"z": "f989436d61b86384",
"name": "",
"mode": "custom",
"build": "merged",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "5",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 950,
"y": 340,
"wires": [
[
"2f41f0de9f974eda"
]
]
},
{
"id": "8fb77b2635ad3637",
"type": "file",
"z": "f989436d61b86384",
"name": "LogFile",
"filename": "filename",
"filenameType": "msg",
"appendNewline": true,
"createDir": true,
"overwriteFile": "false",
"encoding": "none",
"x": 1300,
"y": 340,
"wires": [
[]
]
},
{
"id": "2f41f0de9f974eda",
"type": "function",
"z": "f989436d61b86384",
"name": "LogLine",
"func": "let datetime = new Date().toISOString()\nlet localtime = datetime.toLocaleString().split(\".\")\nmsg.filename = flow.get('FileName');\nmsg.payload = localtime[0] + \",\" + msg.payload.trackTrue + \",\" + msg.payload.speedKnots + \",\" + msg.payload.miles + \",\" + msg.payload.lat + \" \" + msg.payload.latPole + \",\" + msg.payload.lon + \" \" + msg.payload.lonPole + \",\" + msg.payload.angle + \",\" + msg.payload.speed + \",\" + (msg.payload.depth + 0.56) + \",\" + msg.payload.enginehrs + \",\" + msg.payload.rpm / 10 + \",\" + msg.payload.tank0 + \",\" + msg.payload.tank1 + \",\" + msg.payload.oilpress + \",\" + msg.payload.watertemp + \",\" + msg.payload.voltage;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1100,
"y": 340,
"wires": [
[
"8fb77b2635ad3637"
]
]
},
{
"id": "51d90f26156dc3a5",
"type": "function",
"z": "f989436d61b86384",
"name": "enginerpm",
"func": "var data = msg.payload.split(\",\");\nmsg.payload = { \"rpm\": +data[3] }\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 790,
"y": 520,
"wires": [
[
"69eeeb9504fed840"
]
]
},
{
"id": "8f8a7e014c41a3cb",
"type": "udp in",
"z": "f989436d61b86384",
"name": "Nmea in",
"iface": "",
"port": "10110",
"ipv": "udp4",
"multicast": "false",
"group": "",
"datatype": "utf8",
"x": 420,
"y": 360,
"wires": [
[
"e030ac7d47753673"
]
]
}
]