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.

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating custom NMEA sentence
#1
I have a BMP180 working, at the moment the NMEA generator makes an NMEA sentance which opencpn dashboard can read-
$OCMDA,,,1.018,B,22.3,,,,,,,,,,,,,,,*3D

[Image: u4wZTOy.png]

[Image: MvVNlof.png]

What I want to do is have the logbook konni to automatically record pressure as well - do do this apparently it will look for a sentence like..
$WIMDA,30,I,1.02,B,10.1,C,,C,,,,C,158.69,T,,M,3.89 ,N,2,M*37

So -
How do I get a data feed created in node-red to be seen by openplotter so I can make a new nmea sentence? I can get node-red to see a udp feed it's created itself to be seen by node-red but can't get it into openplotter.
Or is there a way for force the nmea generator to write a sentence like$WIMDA,.... instead of $OCMDA,,,1.018,B,22.3,,,,,,,,,,,,,,,*3D ?

I'd like to get node-red working just to know how Smile
TIA
  Reply
#2
Strange! - at my install its exactly opposite!
I get a OCXDR sentence generated which is not shown in the ocpn dashboard, would need the OCMDA - tried to use NMEA converter but gave at the end up as its shown correctly in node-red.

but would also like to use the Konni-logbook with automatic airpressure setting. - I always thought as the dashboard cant show the pressure so the konni will not get it. - but what you observed is totally strange.

BTW - this konni-logbook is really great but would be even better if it is not embedded into ocpn but a separate program in OP as it could then be extended to record automatically also other measures which have nothing to do with ocpn (e.g engine temp, water or fuel levels etc )

just my 2cent!

below the code of my node-red showing pressure and temperature:

[{"id":"e5c38364.12994","type":"websocket in","z":"f471eda8.b7901","name":"","server":"e4c90bec.5fa188","client":"","x":134.25,"y":39,"wires":[["451e867a.4de5e8"]]},{"id":"451e867a.4de5e8","type":"json","z":"f471eda8.b7901","name":"","x":55,"y":105.00000476837158,"wires":[["a468cc97.41c4d","e184c036.78eb4"]]},{"id":"a468cc97.41c4d","type":"jsonpath","z":"f471eda8.b7901","expression":"$.updates..values[?(@.path==\"environment.outside.pressure\")]..value","split":true,"name":"environment.outside.pressure","x":295.00000762939453,"y":105.25000381469727,"wires":[["12298bf.d0d1974","7f7a4106.19ebd"]]},{"id":"e184c036.78eb4","type":"jsonpath","z":"f471eda8.b7901","expression":"$.updates..values[?(@.path==\"environment.outside.temperature\")]..value","split":true,"name":"environment.outside.temperature","x":304.25000762939453,"y":275.5000057220459,"wires":[["21df329f.e12cee","1663880c.4e0a88"]]},{"id":"12298bf.d0d1974","type":"delay","z":"f471eda8.b7901","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":278.75,"y":175.25,"wires":[["2731bba2.40ab64"]]},{"id":"1663880c.4e0a88","type":"delay","z":"f471eda8.b7901","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":273.25,"y":351.5,"wires":[["716908ce.c5e2a8"]]},{"id":"2731bba2.40ab64","type":"function","z":"f471eda8.b7901","name":"Convert to hPa","func":"msg.payload = msg.payload /100 ;\nmsg.payload = msg.payload.toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"x":460.75,"y":177,"wires":[["1ac22cae.ef1e53"]]},{"id":"716908ce.c5e2a8","type":"function","z":"f471eda8.b7901","name":"convert to C","func":"msg.payload = msg.payload -272.15 ;\nmsg.payload = msg.payload.toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"x":448.25,"y":352.5,"wires":[["402d52b1.9012ec"]]},{"id":"1ac22cae.ef1e53","type":"ui_chart","z":"f471eda8.b7901","name":"","group":"8dd292.ec172d7","order":1,"width":"0","height":"0","label":"Surface Pressure (hPa)","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":"72","removeOlderPoints":"","removeOlderUnit":"3600","cutout":"","colors":["#ffff00","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":651,"y":170,"wires":[["2516898a.615516"],[]]},{"id":"301e5b12.5b5234","type":"ui_text","z":"f471eda8.b7901","group":"8dd292.ec172d7","order":2,"width":"0","height":"0","name":"current pressure (hPa)","label":"current pressure","format":"{{msg.payload | number:0}} hPa","layout":"row-spread","x":715.2500152587891,"y":102.50000286102295,"wires":[]},{"id":"d5a4d076.9693f","type":"ui_text","z":"f471eda8.b7901","group":"312485dc.fe0b0a","order":4,"width":"0","height":"0","name":"current temperature ©","label":"current temperature","format":"{{msg.payload | number:1}} °","layout":"row-spread","x":716.7500152587891,"y":278.50000381469727,"wires":[]},{"id":"402d52b1.9012ec","type":"ui_chart","z":"f471eda8.b7901","name":"","group":"312485dc.fe0b0a","order":3,"width":0,"height":0,"label":"Temperature ©","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"basis","nodata":"","ymin":"","ymax":"","removeOlder":"72","removeOlderPoints":"","removeOlderUnit":"3600","cutout":"","colors":["#ffff00","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":647,"y":350.75,"wires":[["dcf50a07.943a98"],[]]},{"id":"2516898a.615516","type":"file","z":"f471eda8.b7901","name":"Chart dump","filename":"/home/pi/.ds-charts/pressure.dump","appendNewline":true,"createDir":true,"overwriteFile":"true","x":750.75,"y":205.25,"wires":[]},{"id":"3b896c8.024a794","type":"json","z":"f471eda8.b7901","name":"","x":497.5,"y":428.25,"wires":[["1ac22cae.ef1e53"]]},{"id":"dcf50a07.943a98","type":"file","z":"f471eda8.b7901","name":"Chart dump","filename":"/home/pi/.ds-charts/temperature.dump","appendNewline":true,"createDir":true,"overwriteFile":"true","x":757.25,"y":392.75,"wires":[]},{"id":"710d185d.82de18","type":"file in","z":"f471eda8.b7901","name":"Chart dump pres","filename":"/home/pi/.ds-charts/pressure.dump","format":"utf8","x":318.25000762939453,"y":429,"wires":[["3b896c8.024a794"]]},{"id":"57473e88.b056f","type":"inject","z":"f471eda8.b7901","name":"Startup Pressure","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":101.75,"y":432.75,"wires":[["710d185d.82de18"]]},{"id":"c1b1d297.1468f","type":"inject","z":"f471eda8.b7901","name":"Startup Temp","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":93,"y":477,"wires":[["a743378e.6513c8"]]},{"id":"a743378e.6513c8","type":"file in","z":"f471eda8.b7901","name":"Chart dump temp","filename":"/home/pi/.ds-charts/temperature.dump","format":"utf8","x":315,"y":478,"wires":[["96369024.2516a"]]},{"id":"96369024.2516a","type":"json","z":"f471eda8.b7901","name":"","x":501,"y":474,"wires":[["402d52b1.9012ec"]]},{"id":"7f7a4106.19ebd","type":"function","z":"f471eda8.b7901","name":"Convert to hPa","func":"msg.payload = msg.payload /100 ;\nmsg.payload = msg.payload.toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":147,"wires":[["301e5b12.5b5234"]]},{"id":"21df329f.e12cee","type":"function","z":"f471eda8.b7901","name":"convert to C","func":"msg.payload = msg.payload -272.15 ;\nmsg.payload = msg.payload.toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"x":449,"y":323,"wires":[["d5a4d076.9693f"]]},{"id":"e4c90bec.5fa188","type":"websocket-listener","z":"","path":"ws://localhost:3000/signalk/v1/stream","wholemsg":"false"},{"id":"8dd292.ec172d7","type":"ui_group","z":"","name":"Pressure","tab":"b2f9c8f1.cf11b8","disp":false,"width":"6"},{"id":"312485dc.fe0b0a","type":"ui_group","z":"","name":"Temperature","tab":"b2f9c8f1.cf11b8","order":2,"disp":false,"width":"6"},{"id":"b2f9c8f1.cf11b8","type":"ui_tab","z":"","name":"Environment","icon":"dashboard"}]
  Reply
#3
(05-29-2017, 10:44 AM)SkipperEarly Wrote: Strange! - at my install its exactly opposite!
I get a OCXDR sentence generated which is not shown in the ocpn dashboard, would need the OCMDA - tried to use NMEA converter but gave at the end up as its shown correctly in node-red.

but would also like to use the Konni-logbook with automatic airpressure setting. - I always thought as the dashboard cant show the pressure so the konni will not get it. - but what you observed is totally strange.
This is what I put into the nmea generator to get an nmea sentence which the opencpn dashboard understands, just tried it with your node-red flow minus the file saving (Thanx! Saves me  together one :Smile  and it seems to work just fine. Having  data all on the same screen with opencpn is very handy under way. 


[Image: fHiQTJx.png]


Quote:BTW - this konni-logbook is really great but would be even better if it is not embedded into ocpn but a separate program in OP as it could then be extended to record automatically also other measures which have nothing to do with ocpn (e.g engine temp, water or fuel levels etc )
Very unlikely, the konni logbook is written as a plugin for opencpn, to stand alone it would mean pretty much starting from scratch. But hope on the horizon , looks like  Sailoog has something in his far reaching sights :Cool I've been using RDDtools to log data which seems like a very good database for time based data but bit of a run around to get it to do things.
  Reply
#4
PaddyB, if opencpn digest $OCMDA sentences, it must also digest $WIMDA. 2 first characters do not define the sentence type, that is the talker ID. Maybe the plugin do not support MDA sentences. Plugins are independent from opencpn core and they support different sentences.

Very important info: https://opencpn.org/wiki/dokuwiki/doku.p..._sentences

Definitely we need a data logging tool on OP core...
  Reply
#5
(05-30-2017, 12:58 PM)Sailoog Wrote: PaddyB, if opencpn digest $OCMDA sentences, it must also digest $WIMDA. 2 first characters do not define the sentence type, that is the talker ID. Maybe the plugin do not support MDA sentences. Plugins are independent from opencpn core and they support different sentences.

Very important info: https://opencpn.org/wiki/dokuwiki/doku.p..._sentences

Definitely we need a data logging tool on OP core...

I think there's something a bit odd with the logbook konni, I've had it working before with WIMDA sentence but not a IIMDA sentence exactly the same,,,
http://www.cruisersforum.com/forums/f129...ost2037644

The plugin says something about it it preferences:
[Image: pNR62Ce.png]

Can't get it working now , and it crashes on a win10 laptop when trying to OK after selecting that box. 
Anyway, I think it's more an opencpn question rather than openplotter. 

Also failed completely trying to send anything to kplex/openplotter from node-red, tried virtual com ports with socat in a linux terminal, which would show up as a dev/pts/3 device and stream data looking at cat but nothing from the nmea diagnostic. 

WOW - from sadness to joy!  Just double checked everything, changed the SK-base-d.py file so it outputs WIMDA sentence from nmea generator instead of OC and it works!! 
Weird!
[Image: 5Ua0bUF.png]
  Reply
#6
OK, sailoog - after some head scratching I can now get nmea messages into kplex from node red. So what seems to happen is.... The sentence created by the nmea generator from a BMP180 sensor $OC....... gets seen by the Opencn dashboard but not the logbook. This sentence created by node red gets recognised by the konni logboog and inserted when a new line is created..
"$WIMDA,30,I,1.02,B,10.1,C,,C,,,,C,158.69,T,,M,3.89 ,N,2,M*17↵"

Strange but true... Smile

One day the world will all use signalk and be a better place Cool
  Reply
#7
really weird, do you mean that logbook only accept MDA sentences from one talker???

We need to keep OC as talker for NMEA sentences generated by some tools like calculation or NMEA generator because we need to filter them. If we do not filter them it could be possible to create dangerous loops.

Good work with node red.
  Reply
#8
@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
  Reply
#9
(05-31-2017, 02: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


Forum Jump:


Users browsing this thread: 1 Guest(s)