Move OUTPUT_MODE logic from rcS to rc.interface.

This commit is contained in:
mcsauder 2018-07-24 11:11:52 -06:00 committed by Beat Küng
parent 57dfcee842
commit 8da1e67050
2 changed files with 103 additions and 101 deletions

View File

@ -36,6 +36,109 @@ then
set MIXER_AUX none set MIXER_AUX none
fi fi
#
# Set the default output mode if none was set.
#
if [ $OUTPUT_MODE == none ]
then
if [ $USE_IO == yes ]
then
# Enable IO output only if IO is present.
if [ $IO_PRESENT == yes ]
then
set OUTPUT_MODE io
fi
else
set OUTPUT_MODE fmu
fi
fi
#
# If OUTPUT_MODE == none then something is wrong with setup and we shouldn't try to enable output.
#
if [ $OUTPUT_MODE != none ]
then
if [ $OUTPUT_MODE == mkblctrl ]
then
if [ $MKBLCTRL_MODE == x ]
then
set MKBLCTRL_ARG "-mkmode x"
fi
if [ $MKBLCTRL_MODE == + ]
then
set MKBLCTRL_ARG "-mkmode +"
fi
if mkblctrl $MKBLCTRL_ARG
then
else
# Error tune.
tune_control play -t 2
fi
fi
if [ $OUTPUT_MODE == hil ]
then
if pwm_out_sim start
then
else
# Error tune.
tune_control play -t 2
fi
fi
if [ $OUTPUT_MODE == tap_esc ]
then
set FMU_MODE rcin
fi
if [ $OUTPUT_MODE == fmu ]
then
if fmu mode_$FMU_MODE $FMU_ARGS
then
else
echo "FMU start failed" >> $LOG_FILE
# Error tune.
tune_control play -t 2
fi
fi
if [ $OUTPUT_MODE == uavcan_esc ]
then
if param compare UAVCAN_ENABLE 0
then
param set UAVCAN_ENABLE 3
fi
fi
if [ $OUTPUT_MODE == io -o $OUTPUT_MODE == uavcan_esc ]
then
sh /etc/init.d/rc.io
fi
#
# Start IO or FMU for RC PPM input if needed.
#
if [ $IO_PRESENT == yes ]
then
if [ $OUTPUT_MODE != io ]
then
sh /etc/init.d/rc.io
fi
else
if [ $OUTPUT_MODE != fmu ]
then
if fmu mode_${FMU_MODE} $FMU_ARGS
then
else
echo "FMU mode_${FMU_MODE} start failed" >> $LOG_FILE
# Error tune.
tune_control play -t 2
fi
fi
fi
fi
if [ $MIXER != none -a $MIXER != skip ] if [ $MIXER != none -a $MIXER != skip ]
then then
# #

View File

@ -468,107 +468,6 @@ else
fi fi
fi fi
#
# Set default output if not set.
#
if [ $OUTPUT_MODE == none ]
then
if [ $USE_IO == yes ]
then
# Enable IO output only if IO is present.
if [ $IO_PRESENT == yes ]
then
set OUTPUT_MODE io
fi
else
set OUTPUT_MODE fmu
fi
fi
# If OUTPUT_MODE == none then something is wrong with setup and we shouldn't try to enable output.
if [ $OUTPUT_MODE != none ]
then
if [ $OUTPUT_MODE == uavcan_esc ]
then
if param compare UAVCAN_ENABLE 0
then
param set UAVCAN_ENABLE 3
fi
fi
if [ $OUTPUT_MODE == mkblctrl ]
then
if [ $MKBLCTRL_MODE == x ]
then
set MKBLCTRL_ARG "-mkmode x"
fi
if [ $MKBLCTRL_MODE == + ]
then
set MKBLCTRL_ARG "-mkmode +"
fi
if mkblctrl $MKBLCTRL_ARG
then
else
# Error tune.
tune_control play -t 2
fi
fi
if [ $OUTPUT_MODE == hil ]
then
if pwm_out_sim start
then
else
# Error tune.
tune_control play -t 2
fi
fi
if [ $OUTPUT_MODE == tap_esc ]
then
set FMU_MODE rcin
fi
if [ $OUTPUT_MODE == fmu ]
then
if fmu mode_$FMU_MODE $FMU_ARGS
then
else
echo "FMU start failed" >> $LOG_FILE
# Error tune.
tune_control play -t 2
fi
fi
if [ $OUTPUT_MODE == io -o $OUTPUT_MODE == uavcan_esc ]
then
sh /etc/init.d/rc.io
fi
#
# Start IO or FMU for RC PPM input if needed.
#
if [ $IO_PRESENT == yes ]
then
if [ $OUTPUT_MODE != io ]
then
sh /etc/init.d/rc.io
fi
else
if [ $OUTPUT_MODE != fmu ]
then
if fmu mode_${FMU_MODE} $FMU_ARGS
then
else
echo "FMU mode_${FMU_MODE} start failed" >> $LOG_FILE
# Error tune.
tune_control play -t 2
fi
fi
fi
fi
# #
# Start mavlink streams. # Start mavlink streams.
# #