torstai 29. elokuuta 2013

First Gauge with SVG and Node.js

I couldn't get javascript access to Canboat's streaming json working with my meager js skills.  I need anyway access also to another streaming source, namely gpsd nmea 0183 data, so I figured I would give wind data a try with Node.js and Websockets.

This turned into a proto with a Node http server that
  • spawns "source" process that mimics canboat:
    • actual captured N2K data from our boat in a file
    • read by simple shell script, output a line per second and piped to
    • canboat analyzer that outputs the message in json, message per line
  • serves a single html file with embedded SVG wind gauge & websocket client that updates the wind direction based on the streamed json messages
  • streames N2K messages in json over websockets with Primus
The whole stack was a breeze and I made really good progress with almost no sidesteps.
The result is in my humble opinion a pretty neat in-browser wind direction visualization that handles  issues such as reconnects automatically. Responsive UI no less, sizes to the size & orientation of your screen/window.



Next steps:
  • capturing a real data set: actual sail or at least motoring around rather than just sitting at the docks
  • getting the whole thing up and running on Pi, accessible via a wifi access point on the Pi
  • adding the gpsd NMEA 0183 data from the plotter (COG etc)
  • calculating and displaying TWA
Apparently there are multiple (1, 2, 3) simple NMEA 0183 parsers in Javascript, have to see which one suits my needs best.

Ei kommentteja:

Lähetä kommentti