mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-22 14:24:21 +08:00
parameters: open export files O_TRUNC to discard previous data
- rcS parameter backup try to directly restore param (FRAM) from backup (in case SD card is removed before successful export) - rcS parameter backup logging rearrange to capture more logging output (param_import_fail.txt) - posix rcS try to keep param backup and restore roughly in sync with NuttX rcS - tinybson fix debug printf format - param_export_internal ensure file descriptor positioned at 0 (precaution)
This commit is contained in:
@@ -7,7 +7,7 @@ param set-default IMU_INTEG_RATE 250
|
||||
if [ "$PX4_SIMULATOR" = "sihsim" ] || [ "$(param show -q SYS_AUTOSTART)" -eq "0" ]; then
|
||||
|
||||
if ! simulator_sih start; then
|
||||
echo "ERROR [init] simulator_sih failed to start"
|
||||
echo "ERROR [init] simulator_sih failed to start"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -46,7 +46,7 @@ elif [ "$PX4_SIMULATOR" = "ignition" ]; then
|
||||
sensor_gps_sim start
|
||||
sensor_mag_sim start
|
||||
else
|
||||
echo "ERROR [init] ign gazebo failed to start"
|
||||
echo "ERROR [init] ign gazebo failed to start"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
@@ -61,7 +61,7 @@ elif [ "$PX4_SIMULATOR" = "ignition" ]; then
|
||||
sensor_gps_sim start
|
||||
sensor_mag_sim start
|
||||
else
|
||||
echo "ERROR [init] ign gazebo failed to start"
|
||||
echo "ERROR [init] ign gazebo failed to start"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ then
|
||||
# shellcheck disable=SC2012
|
||||
REQUESTED_AUTOSTART=$(ls "${R}etc/init.d-posix/airframes" | sed -n 's/^\([0-9][0-9]*\)_'${PX4_SIM_MODEL}'$/\1/p')
|
||||
if [ -z "$REQUESTED_AUTOSTART" ]; then
|
||||
echo "ERROR [init] Unknown model $PX4_SIM_MODEL (not found by name on ${R}etc/init.d-posix/airframes)"
|
||||
echo "ERROR [init] Unknown model $PX4_SIM_MODEL (not found by name on ${R}etc/init.d-posix/airframes)"
|
||||
exit 1
|
||||
else
|
||||
SYS_AUTOSTART=$REQUESTED_AUTOSTART
|
||||
@@ -62,18 +62,46 @@ fi
|
||||
|
||||
# Load parameters
|
||||
set PARAM_FILE parameters.bson
|
||||
param select $PARAM_FILE
|
||||
set PARAM_BACKUP_FILE parameters_backup.bson
|
||||
|
||||
if [ -f $PARAM_FILE ]
|
||||
then
|
||||
if param load
|
||||
param select $PARAM_FILE
|
||||
if [ -f $PARAM_FILE ]; then
|
||||
set +e # disable exit on error control for param import
|
||||
if ! param import
|
||||
then
|
||||
echo "[param] Loaded: $PARAM_FILE"
|
||||
else
|
||||
echo "[param] FAILED loading $PARAM_FILE"
|
||||
echo "ERROR [init] param import failed"
|
||||
|
||||
param dump $PARAM_FILE
|
||||
|
||||
# try to make a backup copy
|
||||
cp $PARAM_FILE param_import_fail.bson
|
||||
|
||||
# try importing from backup file
|
||||
if [ -f $PARAM_BACKUP_FILE ]
|
||||
then
|
||||
echo "[init] importing from parameter backup"
|
||||
|
||||
# dump current backup file contents for comparison
|
||||
param dump $PARAM_BACKUP_FILE
|
||||
|
||||
param import $PARAM_BACKUP_FILE
|
||||
|
||||
# overwrite invalid $PARAM_FILE with backup
|
||||
cp $PARAM_BACKUP_FILE $PARAM_FILE
|
||||
fi
|
||||
|
||||
param status
|
||||
fi
|
||||
set -e # restore exit on error control
|
||||
|
||||
elif [ -f $PARAM_BACKUP_FILE ]; then
|
||||
echo "ERROR [init] primary param file $PARAM_FILE unavailable, using backup $PARAM_BACKUP_FILE"
|
||||
param import $PARAM_BACKUP_FILE
|
||||
fi
|
||||
|
||||
param select-backup $PARAM_BACKUP_FILE
|
||||
|
||||
|
||||
# exit early when the minimal shell is requested
|
||||
[ $RUN_MINIMAL_SHELL = yes ] && exit 0
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ set IOFW "/etc/extras/px4_io-v2_default.bin"
|
||||
set LOGGER_ARGS ""
|
||||
set LOGGER_BUF 8
|
||||
set PARAM_FILE ""
|
||||
set PARAM_BACKUP_FILE ""
|
||||
set RC_INPUT_ARGS ""
|
||||
set SDCARD_AVAILABLE no
|
||||
set SDCARD_EXT_PATH /fs/microsd/ext_autostart
|
||||
@@ -93,6 +94,7 @@ then
|
||||
fi
|
||||
|
||||
set PARAM_FILE /fs/microsd/params
|
||||
set PARAM_BACKUP_FILE "/fs/microsd/parameters_backup.bson"
|
||||
fi
|
||||
|
||||
#
|
||||
@@ -132,27 +134,32 @@ else
|
||||
|
||||
if [ -d "/fs/microsd" ]
|
||||
then
|
||||
dmesg >> /fs/microsd/param_import_fail.txt &
|
||||
|
||||
# try to make a backup copy
|
||||
cp $PARAM_FILE /fs/microsd/param_import_fail.bson &
|
||||
fi
|
||||
cp $PARAM_FILE /fs/microsd/param_import_fail.bson
|
||||
|
||||
# try importing from backup file
|
||||
if [ -f "/fs/microsd/parameters_backup.bson" ]
|
||||
then
|
||||
echo "[init] importing from parameter backup"
|
||||
# try importing from backup file
|
||||
if [ -f $PARAM_BACKUP_FILE ]
|
||||
then
|
||||
echo "[init] importing from parameter backup"
|
||||
|
||||
# dump current backup file contents for comparison
|
||||
param dump /fs/microsd/parameters_backup.bson
|
||||
# dump current backup file contents for comparison
|
||||
param dump $PARAM_BACKUP_FILE
|
||||
|
||||
param import /fs/microsd/parameters_backup.bson
|
||||
param import $PARAM_BACKUP_FILE
|
||||
|
||||
# overwrite invalid $PARAM_FILE with backup
|
||||
cp $PARAM_BACKUP_FILE $PARAM_FILE
|
||||
fi
|
||||
|
||||
param status
|
||||
|
||||
dmesg >> /fs/microsd/param_import_fail.txt &
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $SDCARD_AVAILABLE = yes ]
|
||||
then
|
||||
param select-backup /fs/microsd/parameters_backup.bson
|
||||
param select-backup $PARAM_BACKUP_FILE
|
||||
fi
|
||||
|
||||
if ver hwcmp PX4_FMU_V5X PX4_FMU_V6X
|
||||
@@ -534,6 +541,7 @@ unset IOFW
|
||||
unset LOGGER_ARGS
|
||||
unset LOGGER_BUF
|
||||
unset PARAM_FILE
|
||||
unset PARAM_BACKUP_FILE
|
||||
unset RC_INPUT_ARGS
|
||||
unset SDCARD_AVAILABLE
|
||||
unset SDCARD_EXT_PATH
|
||||
|
||||
Reference in New Issue
Block a user