diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2015-02-15 16:17:13 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-02-15 19:52:02 +0100 |
commit | 2e4c0c3156c72eb2f1ef99008a77fbce939a790e (patch) | |
tree | 69d0d107e61ed9831705830e0ad1d19967e2765e | |
parent | 6fd89aa2bd4fe0e73a5b46c494deba4ff4e1d131 (diff) | |
download | px4-firmware-2e4c0c3156c72eb2f1ef99008a77fbce939a790e.tar.gz px4-firmware-2e4c0c3156c72eb2f1ef99008a77fbce939a790e.tar.bz2 px4-firmware-2e4c0c3156c72eb2f1ef99008a77fbce939a790e.zip |
sensors app: Comment handling of old param values properly
-rw-r--r-- | src/modules/sensors/sensors.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/modules/sensors/sensors.cpp b/src/modules/sensors/sensors.cpp index 666025c71..9a90c84e0 100644 --- a/src/modules/sensors/sensors.cpp +++ b/src/modules/sensors/sensors.cpp @@ -1519,16 +1519,23 @@ Sensors::parameter_update_poll(bool forced) int32_t mag_rot = 0; param_get(param_find(str), &mag_rot); - /* handling of old setups, will be removed */ - if (s == 0) { - int32_t deprecated_mag_rot = 0; - param_get(param_find("SENS_EXT_MAG_ROT"), &deprecated_mag_rot); - - /* if the old param is non-zero, set the new one to the same value */ - if ((deprecated_mag_rot != 0) && (mag_rot <= 0)) { - mag_rot = deprecated_mag_rot; - param_set_no_notification(param_find(str), &mag_rot); - } + /* handling of old setups, will be removed later (noted Feb 2015) */ + int32_t deprecated_mag_rot = 0; + param_get(param_find("SENS_EXT_MAG_ROT"), &deprecated_mag_rot); + + /* + * If the deprecated parameter is non-default (is != 0), + * and the new parameter is default (is == 0), then this board + * was configured already and we need to copy the old value + * to the new parameter. + * The < 0 case is special: It means that this param slot was + * used previously by an internal sensor, but the the call above + * proved that it is currently occupied by an external sensor. + * In that case we consider the orientation to be default as well. + */ + if ((deprecated_mag_rot != 0) && (mag_rot <= 0)) { + mag_rot = deprecated_mag_rot; + param_set_no_notification(param_find(str), &mag_rot); } /* handling of transition from internal to external */ |