This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating custom NMEA sentence
#9
(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 Smile

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"
            ]
        ]
    }
]
Reply


Messages In This Thread
Creating custom NMEA sentence - by PaddyB - 2017-05-29, 02:47 PM
RE: Creating custom NMEA sentence - by PaddyB - 2017-05-29, 04:25 PM
RE: Creating custom NMEA sentence - by Sailoog - 2017-05-30, 05:58 PM
RE: Creating custom NMEA sentence - by PaddyB - 2017-05-30, 07:51 PM
RE: Creating custom NMEA sentence - by PaddyB - 2017-05-31, 11:50 AM
RE: Creating custom NMEA sentence - by Sailoog - 2017-05-31, 04:39 PM
RE: Creating custom NMEA sentence - by PaddyB - 2017-06-01, 08:42 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)