scaryclam/pynmea — pull request #2 by JanezStupar (2012-06-18 11:02:06+00:00)
Title: Expansion of pynmea with additional statements, gadgetpool proprietary STALK sentence support and serialization.

This contribution is sponsored by Visionect d.o.o. Vojkova Ulica 63, 1000 Ljubljana, Slovenia.

Authored by Janez Stupar (www.janezstupar.com).

With this contribution pynmea gains following features:
* New NMEA Sentences (RSA, HSC, MWD, MWV, DBT, DPT, HDM, MTW, VHW, VLW).
* Support for casting data fields into a specified type during parse operation.
* Support for GadgetPool based SEATALK sentence support.
* All the sentence objects can now be created, filled with data and dumped into NMEA sentence (serialization worklfow), thus all supported NMEA sentences are now roundtrippable.

Type casting during parse:
Should we want to parse sentence data into an object type, we add a new entry to the parse map tuple (e.g.: ('Water speed knots','water_speed_knots','decimal') ) and pass a deserialize=True flag to the NMEASentence object constructor.

Creating Sentence object with default values example:
sentence = pynmea.nmea.GLL()
kwargs = {
'lat': 10,
'timestamp': 543543
}
sentence.construct(**kwargs)

print sentence.nmea_sentence
>>> $IIGLL,10,,,,543543,*46'

GadgetPool Seatalk based NMEA sentences are more complex and code should be checked for reference.