It might be possible to implement a set of virtual cast operator overrides, but only float lets us return NAN to indicate that a cast can't be made, so for now we'll stick with just this one.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1614 f9c3cf11-9bcb-44bc-f272-b75c42450872
Note that AP_VarA arrays are still limited by the constraints on the total size of a variable (AP_Var::k_size_max).
Add a basic unit test for arrays; more are needed.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1579 f9c3cf11-9bcb-44bc-f272-b75c42450872
Add pseudo-constant copies of the AP_Meta_calss::Type_id for the standard AP_VarT subclasses. This makes checking the type of a possible AP_Var much cheaper than calling ::meta_cast, as there is no object con/destruction involved.
Add some helper functions for manipulating AP_Vars from Menu interfaces.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1541 f9c3cf11-9bcb-44bc-f272-b75c42450872
Add a non-static version of AP_Meta_class::meta_cast that can be used against any subclass object directly.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1539 f9c3cf11-9bcb-44bc-f272-b75c42450872
Fix prototype for AP_Var_group::serialize so that it's called correctly when saving a group. Now group load/save works.
Add load/save_all and group load/save unit tests.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1533 f9c3cf11-9bcb-44bc-f272-b75c42450872
- We can't count on the first EEPROM scan knowing about everything; new variables may be constructed later so be willing to go back and re-scan the EEPROM if we encounter a new variable that hasn't been loaded yet.
- Sort out where _key actually points (the variable's data) in the EEPROM and get everyone to use the same interpretation.
- Fix return values from ::save and ::load.
- Make it possible to re-save after ::erase_all by de-locating all variables before the EEPROM is blown away.
- Fix args to eeprom_read_block/eeprom_write_block so that we don't spam random memory.
Add unit tests for basic save/load operations.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1532 f9c3cf11-9bcb-44bc-f272-b75c42450872
Now a variable belonging to a group can safely be constructed before the group it belongs to, and the group can be destroyed before its member variables. This greatly simplifies the AP_Var constructor(s).
Remove the lookup-by-index and lookup-by-key interfaces to AP_Var and replace them with first/next interfaces for all variables, and for variables belonging to a specific group. Document their usage. Add an accessor for the key associated with a variable so that search-by-key can be performed by a consumer. Throw away the lookup cache implementation, as it's not required anymore.
Re-layout the EEPROM variable header and tweak the EEPROM space allocator so that it's more resistant to interruptions during variable save.
Fix the global constants so that they work.
Add an interface for erasing all variables in EEPROM (only writes one byte).
Fix unit tests so that they work with the changed interfaces. Also tweak the unit test framework so that it doesn't inline all its code. This is a WIP - many more tests need to be written still.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1531 f9c3cf11-9bcb-44bc-f272-b75c42450872
Fix the comments around AP_Meta_class::meta_cast; they were leftovers from an earlier implementation and entirely not helpful.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1530 f9c3cf11-9bcb-44bc-f272-b75c42450872
Rather than implementing empty default constructors, make sure that AP_Var and friends have useful default constructors instead. This works around AP_Meta_class::meta_cast requiring a default constructor without having empty ctors scattered around.
Add accessors to AP_Var so that the global variable list can be traversed and the group/variable relationship comprehended by outsiders.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1523 f9c3cf11-9bcb-44bc-f272-b75c42450872
The format is a simple TLV format; a tag identifying the variable, a length for the variable, and then the actual data. This format could ultimately be extended to include waypoint/commands as well.
This allows us to load and save groups of variables to EEPROM without having to have a static EEPROM map.
Still needs unit tests and (probably) bugfixing.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1522 f9c3cf11-9bcb-44bc-f272-b75c42450872
This makes it possible to move one resistor on the APM board and feed it PPM directly from a receiver emitting a PPM stream.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1498 f9c3cf11-9bcb-44bc-f272-b75c42450872
- disable NMEA autodetection; false positives are still a risk
- trim down the console output to a minimum; we still need something to help users diagnose potential problems, but the old output was much too verbose
- rather than block forever, only do one autodetect pass for each ::read call. That's still too long (five seconds or so) but better than blocking forever.
- don't block forever if no GPS is attached.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1480 f9c3cf11-9bcb-44bc-f272-b75c42450872
This can make re-opening a port faster (as the free/malloc pair can be avoided) and possibly more robust (in the case where e.g. the heap has been corrupted).
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1479 f9c3cf11-9bcb-44bc-f272-b75c42450872
Added an init string for SiRF receivers that will bring them back out of the binary mode configuration that AP_GPS_Auto sets them to.
Picked up the GPS logging format from the AP_GPS_Auto test.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1469 f9c3cf11-9bcb-44bc-f272-b75c42450872
Major new features:
- No RAM buffer for the NMEA message being parsed; saves 120 bytes of RAM.
- More robust parser, a little less likely to be confused by bad messages.
- Added configuration strings for SiRF, ublox and MediaTek GPS in NMEA mode to select just the messages of interest.
Note that the issue that TinyGPS has with co-ordinates with "different" numbers of decimal digits is addressed in this code.
Size is comparable to the old parser.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1468 f9c3cf11-9bcb-44bc-f272-b75c42450872
Otherwise, we can end up settling on NMEA as a mode just after switching a SiRF GPS to binary mode.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1467 f9c3cf11-9bcb-44bc-f272-b75c42450872
This is a partial workaround for not being able to use PSTR at global scope, e.g. in an argument to a constructor; it makes the intent of the otherwise somewhat bulky declaration of the string more obvious.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1464 f9c3cf11-9bcb-44bc-f272-b75c42450872
Add support for re-opening a port without changing the baudrate or buffer sizes. By passing zero for the parameters that aren't to be changed, code can reconfigure a port without needing to know how it was originally configured.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1462 f9c3cf11-9bcb-44bc-f272-b75c42450872