(2017-05-31, 07:44 PM)SkipperEarly Wrote: @PaddyB can you please share the node-red code - thanks
have also raised a bug/feature report on ocpn logbook tracker as FS#2233 - pi logbook NMEA input,
suggest everyone votes for it then it may get attention to the ocpn developers
Voted , good call .
Node red to convert "$OCMDA,30.06,I,1.018,B,20.2,C,,,,,,,,,,,,,,*1F" into "$WIMDA,30.06,I,1.018,B,20.2,C,,,,,,,,,,,,,,*d"
This has it's own kplex entries - in-10.10.10.1:10108 and out-127.0.0.1:10112. Maybe not necessary, I don't fully understand the inner workings of UDP/TCP yet.
Code:
[
{
"id": "a40d315e.6d623",
"type": "udp in",
"z": "dcf0a43.0c79158",
"name": "",
"iface": "",
"port": "10112",
"ipv": "udp4",
"multicast": "false",
"group": "",
"datatype": "utf8",
"x": 200,
"y": 500,
"wires": [
[
"983684db.178fa8",
"4bdefe26.a6557"
]
]
},
{
"id": "8f7e9341.ce0e1",
"type": "debug",
"z": "dcf0a43.0c79158",
"name": "",
"active": false,
"console": "false",
"complete": "false",
"x": 1090,
"y": 500,
"wires": []
},
{
"id": "4bdefe26.a6557",
"type": "debug",
"z": "dcf0a43.0c79158",
"name": "",
"active": false,
"console": "false",
"complete": "false",
"x": 390,
"y": 600,
"wires": []
},
{
"id": "983684db.178fa8",
"type": "switch",
"z": "dcf0a43.0c79158",
"name": "Filter just pressure",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": "OCMDA*",
"vt": "str",
"case": true
}
],
"checkall": "true",
"outputs": 1,
"x": 430,
"y": 520,
"wires": [
[
"85be98e1.ebdaf8"
]
]
},
{
"id": "85be98e1.ebdaf8",
"type": "function",
"z": "dcf0a43.0c79158",
"name": " '$OC\" to\"$WI\"",
"func": "var nmeaFull=msg.payload;\n\nvar nmea=nmeaFull.substring(6 ); //\nnmea = '$WIMDA' + nmea;\n\n\nmsg.payload = nmea;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 610,
"y": 520,
"wires": [
[
"15037269.71db2e"
]
]
},
{
"id": "f276f15e.2e3c6",
"type": "udp out",
"z": "dcf0a43.0c79158",
"name": "",
"addr": "10.10.10.1",
"iface": "",
"port": "10108",
"ipv": "udp4",
"outport": "",
"base64": false,
"multicast": "false",
"x": 1120,
"y": 560,
"wires": []
},
{
"id": "5d7d539b.4836dc",
"type": "function",
"z": "dcf0a43.0c79158",
"name": "calc checksum",
"func": "var nmea = msg.payload;\nvar checksum = 0; \n\nfor(var i = 0; i < nmea.length; i++) { \n checksum = checksum ^ nmea.charCodeAt(i); \n}\nchecksum = checksum.toString(16); //convert to hex\nnmea = '$' + nmea + '*' + checksum; //make the full nmea sentence again\n\nmessage = 'Full message =' + nmea + '\\r\\n' + 'Checksum = ' + checksum ;\n\nmsg.payload = nmea;\nmsg.payload = msg.payload+\"\\r\\n\"\n\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 840,
"y": 600,
"wires": [
[
"8f7e9341.ce0e1",
"f276f15e.2e3c6"
]
]
},
{
"id": "15037269.71db2e",
"type": "function",
"z": "dcf0a43.0c79158",
"name": "Strip front and back",
"func": "var nmeaFull=msg.payload;\n\nvar nmeaStripped=nmeaFull.substring(1, nmeaFull.indexOf(\"*\")); //cut of the leading \"$\" and the bad checksum\nmsg.payload = nmeaStripped;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 820,
"y": 500,
"wires": [
[
"5d7d539b.4836dc"
]
]
}
]