mavlink/mavlink — pull request #107 by brucecrevensten (2013-03-26 03:37:18+00:00)
Title: Javascript MAVLink generator for Node.js

This commit adds initial support for generating a MAVLink message parser for Node.js. Documentation for usage is in the README.MD file in the ```pymavlink/generator/javascript/``` directory.

The intent of implementing this with Node.js is to take advantage of Node's event-based model, so that a GCS can be reactive to _events_ instead of polling, and to enable tighter integration with modern web frameworks and technologies in a single language stack -- for example, sharing a synchronized state between multiple clients through Socket.io and other Node technologies.

This work is preliminary, and here's a rundown of its status:

* It's been tested to parse messages from the ArduCopter 2.8.1 APM running in SITL mode, and succeeds at parsing these messages.
* It generates byte-identical packed messages (when compared to the Python implementation) for most messages.
* It's been integrated with a ground station, under development, and successfully shows the status of a UAV (SITL, and xbee/APM2).
* There's a test suite present, written with Mocha/Should, which can be expanded if issues are identified.

Some gotcha's and todo's remain:

* Make it generate idiomatic javascript instead of a fairly rote translation from the Python
* Further integrate it with a ground station to see if problems lurk in the inky shadows
* The JS library that is implementing the pack/unpack functions doesn't match Python's struct library. For example, it doesn't support the q or Q flags representing int64_t and uint64_t, respectively. Those have been replaced with d, double, for the moment. At least some message types may need massaging to correctly support encoding/decoding.

Even though this work is early, I think there's value in getting it out into the community, since there's interest and relevant projects (looking at you, Mavelous) where this may be of use.