There's a price for everything, hehe...
I've tried to increase white space and organization to make it more readable, but let's be honest... conditional compilation is ugly.
Before accessing a part, you must check its valid
flag. Fortunately, this adds only one bit per member. See Streamers.cpp for an example of accessing every data member. That file also shows how to accommodate different builds: all references to 'gps_fix' members are wrapped with conditional compilation #ifdef
/#endif
statements. If you do not plan to support multiple configurations, you do not need to use #ifdef
/#endif
statements.
Parsing without buffers, or in place, means that you must be more careful about when you access data items.
In general, using the fix-oriented methods available
and read
are atomically safe. You can access any parts of your fix
structure, at any time.
If you are using the advanced character-oriented methods:
- You must wait to access the internal
gps.fix()
until after the entire sentence has been parsed. - Only 3 example programs use these methods: NMEAblink, NMEAorder and NMEAdiagnostic. These examples simply
decode
until a sentence is COMPLETED. SeeGPSloop()
in NMEAdiagnostic.ino. - Member function
gps.is_safe()
can also be used to determine when it is safe to access the internalgps.fix()
. - Received data errors can cause invalid field values to be set in the internal fix before the CRC is fully computed. The CRC will catch most of those, and the internal fix members will then be marked as invalid.
By enabling one of the merging methods, fixes will accumulate data from all received sentences. The code required to implement those different techniques is more complicated than simply setting a structure member.
You are not restricted from having other instances of fix; you can copy or merge a some or all of a new fix into another copy if you want.
You've been warned! ;)
Although most of the RAM reduction is due to eliminating buffers, some of it is from trading RAM for additional code (see Nominal Program Space above). And, as I mentioned, the readabilty (i.e., goodness) suffers from its configurability.