Saturday, December 31, 2016

NMEA Multiplexer, OpenCPN, GPSd...

I have been working on an NMEA Multiplexer that can run on small boards, like the Raspberry PI Zero. The code is available on github, see the documentation in the README.md.

It allows to mix all kinds of NMEA Sources into a single (or multiple) stream(s). You can read from Serial Ports, Log file(s), TCP, WebSocket, Sensors (like BME280, HTU21DF, LSM303, etc), merge those data and rebroadcast them on Serial port, TCP, Log file, WebSocket, GPSd, etc. UDP is being worked on.

Data can also be computed and injected in the output stream, like True Wind, Current direction and speed, etc.

As a graphical desktop can be cumbersome on small boards, the Multiplexer comes with a tiny HTTP server that provides a Web UI and REST services to allow remote Admin.

It also comes with several demos and samples
This all works just fine with OpenCPN, SeaWi, that can take TCP streams as NMEA Data Input.
I was also wondering about GPSd. I had some mixed feelings about it. Mostly, I was asking myself "Why should I parse GPSd json objects if I can parse NMEA Sentences?", and could not find any satisfying reason. The topic is mentioned on the GPSd web site's FAQ pages, but nothing clear (to me) came up from that.
Interestingly, OpenCPN can also take GPSd streams as input. But there is a trick.
The first GPSd exchange begins with a ?WATCH request. It is followed by a JSON Object like this:
  ?WATCH={"enable":true,"json":true}
... and here is the trick, OpenCPN sends a
 ?WATCH={"enable":true,"nmea":true}
This nmea option is "poorly" documented, but very useful. Instead of sending JSON objects, GPSd spits out the raw NMEA sentences, as they were read. Then GPSd is just a regular TCP stream, and OpenCPN already knows how to parse the NMEA sentences it delivers. This way, GPSd is not limited to strictly GPS-related sentences. It can convey all NMEA sentences, Boat Speed related, Wind related, etc. This is what the GPSd forwarder that comes with the Multiplexer is doing.
Happy Streaming, happy new year!

2 comments:

  1. Salut ma biche

    Y a que les photos qui intéressent ;-) Sur l'image "GPS" les différents points sur la carte du monde : Est ce que ce sont les positions des satellites "GPS"?

    Beau boulot comme d'habitude, ma compréhention s'arrêtant aux images. J'tais pas donné les droit pour ma photo en haut de ton blog
    Bises
    Captain KOUKOU

    ReplyDelete
  2. Pour la position des satellites sur la carte: les chaines GSV donnent l'azimuth et la hauteur des satellites en vue.
    Avec la position de l'observateur, il est facile de determiner la Position Geographique du satellite. Si l'elevation du satellite est X, et son azimuth Z, alors la position geographique du satellite est a ((90 - X) * 60) nm dans le Z, a partir de la position de l'observateur. Les hauteurs restituees par les chaines GSV sont arrondies au degre le plus proche. Mais ca donne une idee de la position du satellite...
    Si c'est pas assez clair, je peux faire un petit dessin ;)
    Just let me know.

    ReplyDelete