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
Correct for GPS Rollover Week
#7
Try importing this to Node-RED. It should work for a couple of more years at least! You'll have to add a Node-RED UDP incoming port to the NMEA0183 tab, eliminate the existing incoming USB from there, and make sure that the Node-RED incoming serial connection is the right name and speed.

Code:
[
    {
        "id": "7d9ed390.b02dbc",
        "type": "switch",
        "z": "7cd8543c.064e8c",
        "name": "Filter just VTG, GGA, GLL and RMC",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "regex",
                "v": "^(?=.*GPVTG)",
                "vt": "str",
                "case": false
            },
            {
                "t": "regex",
                "v": "^(?=.*GPGGA)",
                "vt": "str",
                "case": false
            },
            {
                "t": "regex",
                "v": "^(?=.*GPGLL)",
                "vt": "str",
                "case": false
            },
            {
                "t": "regex",
                "v": "^(?=.*GPRMC)",
                "vt": "str",
                "case": false
            }
        ],
        "checkall": "true",
        "outputs": 4,
        "x": 570,
        "y": 440,
        "wires": [
            [
                "bd93a857.327338"
            ],
            [
                "899b1d74.c9bf4"
            ],
            [
                "f7463f8c.db9b2"
            ],
            [
                "cc00bb9.9d86048"
            ]
        ],
        "inputLabels": [
            "Input"
        ],
        "outputLabels": [
            "VGT",
            "GGA",
            "GLL",
            "RMC"
        ]
    },
    {
        "id": "a9aaedb5.75839",
        "type": "function",
        "z": "7cd8543c.064e8c",
        "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\nvar msg1 = {\n     payload: msg.payload\n };\n return msg1;",
        "outputs": 1,
        "noerr": 0,
        "x": 1160,
        "y": 440,
        "wires": [
            [
                "3555a419.0e451c",
                "faa406d0.551a88"
            ]
        ]
    },
    {
        "id": "3555a419.0e451c",
        "type": "udp out",
        "z": "7cd8543c.064e8c",
        "name": "",
        "addr": "127.0.0.1",
        "iface": "",
        "port": "10108",
        "ipv": "udp4",
        "outport": "",
        "base64": false,
        "multicast": "false",
        "x": 1400,
        "y": 340,
        "wires": []
    },
    {
        "id": "5d1cb56c.197b9c",
        "type": "comment",
        "z": "7cd8543c.064e8c",
        "name": "This takes NMEA Output, changes date string and adds checksum",
        "info": "",
        "x": 800,
        "y": 140,
        "wires": []
    },
    {
        "id": "9306b8b9.958998",
        "type": "serial in",
        "z": "7cd8543c.064e8c",
        "name": "NMEA Input",
        "serial": "c5d7ff46.19d73",
        "x": 230,
        "y": 580,
        "wires": [
            [
                "7d9ed390.b02dbc"
            ]
        ]
    },
    {
        "id": "7db6213c.a5dd5",
        "type": "inject",
        "z": "7cd8543c.064e8c",
        "name": "Inject GLL String",
        "topic": "",
        "payload": "$GPGLL,5930.030,N,00254.792,E,163415,A",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 240,
        "y": 360,
        "wires": [
            [
                "7d9ed390.b02dbc"
            ]
        ]
    },
    {
        "id": "dbf41ca.eaa14e",
        "type": "inject",
        "z": "7cd8543c.064e8c",
        "name": "Inject RMC String",
        "topic": "",
        "payload": "$GPRMC,163415,A,5930.030,N,00254.792,E,00.0,000.,171197,000.8,E*79",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 238,
        "y": 436.9999876022339,
        "wires": [
            [
                "7d9ed390.b02dbc"
            ]
        ]
    },
    {
        "id": "faa406d0.551a88",
        "type": "debug",
        "z": "7cd8543c.064e8c",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "false",
        "x": 1370,
        "y": 540,
        "wires": []
    },
    {
        "id": "bd93a857.327338",
        "type": "function",
        "z": "7cd8543c.064e8c",
        "name": "Create VTG string",
        "func": "var nmeaFull=msg.payload;\n\nvar nmeaSplit=nmeaFull.split(\",\");\n   \nvar nmeaFinal=\"NRVTG,\";\n\nvar i=\"1\";\n\ndo {\n    nmeaFinal += nmeaSplit[i] + \",\";\n    i++;\n}\nwhile (i < 8);\n\nnmeaFinal=nmeaFinal+nmeaSplit[8];\n\nmsg.payload = nmeaFinal;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 890,
        "y": 320,
        "wires": [
            [
                "a9aaedb5.75839"
            ]
        ]
    },
    {
        "id": "899b1d74.c9bf4",
        "type": "function",
        "z": "7cd8543c.064e8c",
        "name": "Create GGA string",
        "func": "var nmeaFull=msg.payload;\n\nvar nmeaSplit=nmeaFull.split(\",\");\n   \nvar nmeaFinal=\"NRGGA,\";\n\nvar i=\"1\";\n\ndo {\n    nmeaFinal += nmeaSplit[i] + \",\";\n    i++;\n}\nwhile (i < 14);\n\nnmeaFinal=nmeaFinal+nmeaSplit[14];\n\nmsg.payload = nmeaFinal;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 890,
        "y": 400,
        "wires": [
            [
                "a9aaedb5.75839"
            ]
        ]
    },
    {
        "id": "f41432f6.85224",
        "type": "inject",
        "z": "7cd8543c.064e8c",
        "name": "Inject GGA String",
        "topic": "",
        "payload": "$GPGGA,163415,5930.030,N,00254.792,E,1,04,001,0001,M,040,M,,",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 239.99993133544922,
        "y": 279.9999170303345,
        "wires": [
            [
                "7d9ed390.b02dbc"
            ]
        ]
    },
    {
        "id": "db9fcf68.9388c",
        "type": "inject",
        "z": "7cd8543c.064e8c",
        "name": "Inject VGT String",
        "topic": "",
        "payload": "$GPVTG,000,T,359,M,00.0,N,00.0,K",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 239.99993133544922,
        "y": 199.99991703033447,
        "wires": [
            [
                "7d9ed390.b02dbc"
            ]
        ]
    },
    {
        "id": "f7463f8c.db9b2",
        "type": "function",
        "z": "7cd8543c.064e8c",
        "name": "Create GLL string",
        "func": "var nmeaFull=msg.payload;\n\nvar nmeaSplit=nmeaFull.split(\",\");\n   \nvar nmeaFinal=\"NRGLL,\";\n\nvar i=\"1\";\n\ndo {\n    nmeaFinal += nmeaSplit[i] + \",\";\n    i++;\n}\nwhile (i < 6);\n\nnmeaFinal=nmeaFinal+nmeaSplit[6];\n\nmsg.payload = nmeaFinal;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 890,
        "y": 480,
        "wires": [
            [
                "a9aaedb5.75839"
            ]
        ]
    },
    {
        "id": "cc00bb9.9d86048",
        "type": "function",
        "z": "7cd8543c.064e8c",
        "name": "Create RMC string",
        "func": "var nmeaFull=msg.payload;\n\nvar nmeaStripped=nmeaFull.substring(1, nmeaFull.indexOf(\"*\"));\n\nvar nmeaSplit=nmeaStripped.split(\",\");\n\nvar nmeaYear=nmeaSplit[9].substring(4, 6);\nvar nmeaMonth=nmeaSplit[9].substring(2, 4);\nvar nmeaDay=nmeaSplit[9].substring(0, 2);\n\nvar nmeaYearInt=parseInt(nmeaYear)+1920;\nvar nmeaYearStr=nmeaYearInt.toString();\nnmeaYear=nmeaYearStr.substring(2,4);\n\nnmeaSplit[9]=nmeaDay+nmeaMonth+nmeaYear;\n\nvar nmeaFinal=\"NRRMC,\";\n\nvar i=\"1\";\n\ndo {\n    nmeaFinal += nmeaSplit[i] + \",\";\n    i++;\n}\nwhile (i < 11);\n\nnmeaFinal=nmeaFinal+nmeaSplit[11];\n\nmsg.payload = nmeaFinal;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 890,
        "y": 560,
        "wires": [
            [
                "a9aaedb5.75839"
            ]
        ]
    },
    {
        "id": "c5d7ff46.19d73",
        "type": "serial-port",
        "z": "",
        "serialport": "/dev/ttyOP_485",
        "serialbaud": "4800",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "newline": "\\n",
        "bin": "false",
        "out": "char",
        "addchar": false
    }
]
Reply


Messages In This Thread
Correct for GPS Rollover Week - by Celestine - 2017-07-01, 03:27 PM
RE: Correct for GPS Rollover Week - by abarrow - 2017-07-01, 05:11 PM
RE: Correct for GPS Rollover Week - by Celestine - 2017-07-04, 12:05 PM
RE: Correct for GPS Rollover Week - by Sailoog - 2017-07-01, 08:55 PM
RE: Correct for GPS Rollover Week - by abarrow - 2017-07-01, 09:04 PM
RE: Correct for GPS Rollover Week - by Celestine - 2017-07-02, 10:30 AM
RE: Correct for GPS Rollover Week - by abarrow - 2017-07-04, 04:24 PM
RE: Correct for GPS Rollover Week - by Celestine - 2017-07-05, 07:17 AM
RE: Correct for GPS Rollover Week - by Celestine - 2017-07-05, 08:59 AM
RE: Correct for GPS Rollover Week - by abarrow - 2017-07-05, 01:52 PM
RE: Correct for GPS Rollover Week - by andy kopac - 2020-05-07, 09:12 PM
RE: Correct for GPS Rollover Week - by Sailoog - 2020-05-08, 09:58 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)