rcS: add airframe parameter versioning and extend SYS_AUTOCONFIG

This commit is contained in:
Beat Küng
2019-04-02 10:13:56 +02:00
parent 46c4a68b62
commit 0bb5225370
2 changed files with 28 additions and 6 deletions

View File

@@ -57,6 +57,12 @@ set SDCARD_MIXERS_PATH /fs/microsd/etc/mixers
set USE_IO no
set VEHICLE_TYPE none
# Airframe parameter versioning: airframe maintainers can set this in the
# airframe startup script, and then increase it by one whenever an airframe
# parameter is updated - it will ensure that these parameters will be updated
# when the firmware is flashed.
set PARAM_DEFAULTS_VER 1
#
# Mount the procfs.
#
@@ -161,7 +167,12 @@ else
param reset_nostart RC* COM_FLTMODE* LND_FLIGHT_T_* TC_* CAL_ACC* CAL_GYRO*
set AUTOCNF yes
else
set AUTOCNF no
if param compare SYS_AUTOCONFIG 2
then
set AUTOCNF yes
else
set AUTOCNF no
fi
fi
#
@@ -473,6 +484,16 @@ else
#
sh /etc/init.d/rc.logging
if ! param compare SYS_PARAM_VER ${PARAM_DEFAULTS_VER}
then
echo "Switched to different parameter version. Resetting parameters."
param set SYS_PARAM_VER ${PARAM_DEFAULTS_VER}
param set SYS_AUTOCONFIG 2
param save
reboot
fi
#
# End of autostart.
#
@@ -503,6 +524,7 @@ unset MIXER_FILE
unset MK_MODE
unset MKBLCTRL_ARG
unset OUTPUT_MODE
unset PARAM_DEFAULTS_VER
unset PARAM_FILE
unset PWM_AUX_DISARMED
unset PWM_AUX_MAX

View File

@@ -56,10 +56,9 @@ PARAM_DEFINE_INT32(SYS_AUTOSTART, 0);
* Platform-specific values are used if available.
* RC* parameters are preserved.
*
* @min 0
* @max 1
* @value 0 Keep parameters
* @value 1 Reset parameters
* @value 2 Reload airframe parameters
* @group System
*/
PARAM_DEFINE_INT32(SYS_AUTOCONFIG, 0);
@@ -144,9 +143,10 @@ PARAM_DEFINE_INT32(SYS_COMPANION, 0);
/**
* Parameter version
*
* This monotonically increasing number encodes the parameter compatibility set.
* whenever it increases parameters might not be backwards compatible and
* ground control stations should suggest a fresh configuration.
* This is used internally only: an airframe configuration might set an expected
* parameter version value via PARAM_DEFAULTS_VER. This is checked on bootup
* against SYS_PARAM_VER, and if they do not match, parameters from the airframe
* configuration are reloaded.
*
* @min 0
* @group System