Commit Graph

17 Commits

Author SHA1 Message Date
DrZiplok@gmail.com b614aca274 Add a template AP_VarA that defines a variable that is an array of some basic type. This is like AP_VarT for arrays, with minor changes in behaviour consistent with the difference between regular variables and arrays.
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
2011-01-30 20:58:34 +00:00
DrZiplok@gmail.com 34f43934da Move the unit test framework out of the unit tests. Add unit tests for the k_typeid_* constants.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1543 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-23 23:59:26 +00:00
DrZiplok@gmail.com 4b21f3485a Improve performance when saving a number of variables that don't have space allocated in the EEPROM. This avoids scanning the entire EEPROM every time a variable that has not yet had space allocated is written.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1534 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-23 09:56:58 +00:00
DrZiplok@gmail.com 655f7a21ff Fix ::save_all/::load_all so that they check the correct criteria for opt-out. Now load/save_all work.
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
2011-01-23 09:27:58 +00:00
DrZiplok@gmail.com e7da843d90 Fixes for EEPROM space allocation and mapping.
- 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
2011-01-23 08:11:53 +00:00
DrZiplok@gmail.com 39fea200ca I never liked the plan that variable groups could only be statically scoped; it was much too fragile. These changes address that issue by splitting the global variable list into two lists, one for standalone variables (including groups), and one for variables that are members of a group.
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
2011-01-23 06:52:59 +00:00
DrZiplok@gmail.com 39b718fce0 Implement the missing AP_Var_group::*serialize functions.
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
2011-01-22 18:42:44 +00:00
DrZiplok@gmail.com 30d9a92c4e Implement a pure data serialisation load/save model for AP_Var.
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
2011-01-22 08:37:52 +00:00
DrZiplok@gmail.com 96d2dc33fe Formatting and naming changes for conformance with the ArduPilot Coding Conventions.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1502 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-16 09:14:21 +00:00
DrZiplok@gmail.com dd6ede36ee Add more unit tests for AP_Var.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1466 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-10 01:44:23 +00:00
DrZiplok 0e868ca343 More unit tests.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1447 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-05 07:40:35 +00:00
DrZiplok@gmail.com d8046957c6 Unit tests for scope-based address offsetting.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1418 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-04 08:50:24 +00:00
DrZiplok 57f3f4e65b Beef up the unit tests for AP_Var. Most of the basic functionality is now covered.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1403 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-03 02:29:17 +00:00
DrZiplok a3a9fe59e3 Following discussions with James, a complete rewrite of AP_Var.
The overriding principle here is to keep the use of AP_Vars as simple as possible, whilst letting the implementation do useful things behind the scenes.  To that end, we define AP_Float, AP_Int8, AP_Int16 and AP_Int32.  These are strongly typed, so that there is no ambiguity about what a variable "really" is.

The classes behave like the variables they are storing; you can use an AP_Float in most places you would use a regular float; you can add to it, multiply by it, etc.  If it has been given an address in EEPROM you can load and save it.

Variables can be given names, and if they are named then they can be looked up.  This allows e.g. a GCS or a test tool to find and traffic in variables that it may not explicitly know about.

AP_Var does not attempt to solve the problem of EEPROM address space management.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1399 f9c3cf11-9bcb-44bc-f272-b75c42450872
2011-01-02 22:14:36 +00:00
jasonshort 80a5016658 Wasn't compiling.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@1213 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-12-20 02:34:46 +00:00
DrZiplok@gmail.com 064dda10bf Provide an easy way to print stuff before displaying the prompt.
git-svn-id: https://arducopter.googlecode.com/svn/trunk@545 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-24 06:18:59 +00:00
DrZiplok@gmail.com eb6113e685 Add a simple commandline menu library.
The library has an interface suitable for both interactive and automated use (i.e. Arduino console or GCS operation).


git-svn-id: https://arducopter.googlecode.com/svn/trunk@544 f9c3cf11-9bcb-44bc-f272-b75c42450872
2010-09-24 05:50:02 +00:00