NinjaFlight
|
The configuration format and external protocol use some of the same concepts as SAE J1939. A parameter group (PG) is a set of parameters belonging to the same topic and are stored and sent together. A parameter group instance has a unique parameter group number (PGN). Each parameter also has a suspect parameter number (SPN) which can be used to get or set a parameter directly.
When used as on-wire formats structures should be packed to give the same in storage, in memory, and on-wire format. However care must be taken over memory alignment issues when packing structures.
The PGs can be defined on a system-wide basis on a profile specific basis. profiles can be activated on the fly.
The storage consists of a header, zero or more PGs, a footer and a checksum. To keep the RAM usage low, the parameters are written directly to flash which means that things that are only known at the end, such as the size are stored in the footer. The checksum is written after the footer.
The header holds:
Each stored PG holds:
The footer holds:
The checksum is based on the header, PGs, and footer.
The PG registrations hold similar but not identical information (e.g. the profile number is not known until it is stored).
All fields are reset to 0 upon initialisation and then if a reset function is defined for the group then initial settings can be defined by the system.
Upgrades are done at the PG level and are detected by a difference in size or version. New fields can be added to the end of the parameter group. The reset and initialisation function is called before upgrading so new fields will first be reset to 0 and then initialised by the system if defined.
Note: Currently the code does not check the version field.
Downgrades are done at the PG level. Any trailing, unrecognised fields will be silently dropped on load. Saving the config back to flash will discard these unrecognised fields.
An incompatible change is where a field is inserted, deleted from the middle, reordered, resized (including changing the size of a contained array), or has the meaning changed. Such changes should be handled by bumping the PG version field or allocating a new PGN.