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
Checksums on incoming NMEA strings
#3
(2017-06-27, 08:49 PM)abarrow Wrote: Have I taken myself down a rabbit hole here? Is there some other magic that I'm missing in Node-RED or KPLEX configuration that will do what I need to do? Am I wrong about the need for checksums and the other depth metrics in the strings I'm getting?

Your thoughts would be most appreciated.

Node red might be an easier route - how does the nmea data get into the Pi from the ST60? 

You might be able to tweak this flow to do something usedful. 

This gets nmea data from openplotter port 10109 (opencpn output), then filters for just OCMDA messages then it changes the talker ID to WI - $WIMDA, afte rthat it strips the starting  '$' and also strips the checksum, then creates a new checksum and linefeed. Then it's output to UDP port 10108, Openplotter has a new UDP input port 10108 added in the nmea tab to get the data back into openplotter/kplex . (All this is because the konni logbook only seems to accept WIMDA sentences to autofill new log entries with pressure).
You might be able to fiddle with this changing the filter or  with a serial input node to do something useful. 

HTH





[Image: t9JkR9c.png]




Code:
[
   {
       "id": "8821724b.6009d",
       "type": "debug",
       "z": "f2a52aa4.57c488",
       "name": "",
       "active": false,
       "console": "false",
       "complete": "false",
       "x": 765.0000495910645,
       "y": 1570.0000495910645,
       "wires": []
   },
   {
       "id": "5fdabb0b.436d14",
       "type": "switch",
       "z": "f2a52aa4.57c488",
       "name": "Filter just pressure",
       "property": "payload",
       "propertyType": "msg",
       "rules": [
           {
               "t": "regex",
               "v": "^(?=.*OCMDA)",
               "vt": "str",
               "case": false
           }
       ],
       "checkall": "true",
       "outputs": 1,
       "x": 230,
       "y": 1580,
       "wires": [
           [
               "163e594f.d46a67",
               "37b1c3cb.b714ec"
           ]
       ]
   },
   {
       "id": "37b1c3cb.b714ec",
       "type": "function",
       "z": "f2a52aa4.57c488",
       "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": 337.0000305175781,
       "y": 1516.9999647140503,
       "wires": [
           [
               "264b1a9d.6a8576"
           ]
       ]
   },
   {
       "id": "aae69ba7.ffae88",
       "type": "function",
       "z": "f2a52aa4.57c488",
       "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": 572.0000305175781,
       "y": 1512.0000495910645,
       "wires": [
           [
               "8821724b.6009d",
               "dbb55dc2.373dd"
           ]
       ]
   },
   {
       "id": "264b1a9d.6a8576",
       "type": "function",
       "z": "f2a52aa4.57c488",
       "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": 467.0000991821289,
       "y": 1568.0000457763672,
       "wires": [
           [
               "aae69ba7.ffae88"
           ]
       ]
   },
   {
       "id": "dbb55dc2.373dd",
       "type": "udp out",
       "z": "f2a52aa4.57c488",
       "name": "",
       "addr": "127.0.0.1",
       "iface": "",
       "port": "10108",
       "ipv": "udp4",
       "outport": "",
       "base64": false,
       "multicast": "false",
       "x": 795.0000915527344,
       "y": 1517.000072479248,
       "wires": []
   },
   {
       "id": "3ad88f03.0c91a",
       "type": "tcp in",
       "z": "f2a52aa4.57c488",
       "name": "",
       "server": "client",
       "host": "10.10.10.1",
       "port": "10109",
       "datamode": "stream",
       "datatype": "utf8",
       "newline": "",
       "topic": "",
       "base64": false,
       "x": 100,
       "y": 1520,
       "wires": [
           [
               "5fdabb0b.436d14"
           ]
       ]
   },
   {
       "id": "cda80705.74ea58",
       "type": "comment",
       "z": "f2a52aa4.57c488",
       "name": "This flow creats the WIMNA sentance required by Opencpn logbook to create a pressure entry",
       "info": "",
       "x": 480,
       "y": 1460,
       "wires": []
   },
   {
       "id": "163e594f.d46a67",
       "type": "debug",
       "z": "f2a52aa4.57c488",
       "name": "",
       "active": false,
       "console": "false",
       "complete": "false",
       "x": 460.00001525878906,
       "y": 1608.000051498413,
       "wires": []
   }
]
Reply


Messages In This Thread
Checksums on incoming NMEA strings - by abarrow - 2017-06-27, 08:49 PM
RE: Checksums on incoming NMEA strings - by JD1 - 2017-06-28, 03:08 AM
RE: Checksums on incoming NMEA strings - by PaddyB - 2017-06-28, 10:06 AM
RE: Checksums on incoming NMEA strings - by JD1 - 2017-06-28, 06:24 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)