Files
bizhang_-obav/ROMFS/px4fmu_common/init.d/rc.interface

172 lines
3.2 KiB
Plaintext
Raw Normal View History

#!nsh
#
# Script to configure control interface
#
set SDCARD_MIXERS_PATH /fs/microsd/etc/mixers
2014-03-06 23:11:13 +01:00
if [ $MIXER != none -a $MIXER != skip ]
then
#
# Load main mixer
#
2015-03-01 20:14:41 -08:00
if [ $MIXER_AUX == none -a $USE_IO == yes ]
then
set MIXER_AUX $MIXER.aux
fi
2015-01-06 19:53:52 +01:00
# Use the mixer file from the SD-card if it exists
if [ -f $SDCARD_MIXERS_PATH/$MIXER.main.mix ]
then
set MIXER_FILE $SDCARD_MIXERS_PATH/$MIXER.main.mix
# Try out the old convention, for backward compatibility
else
if [ -f $SDCARD_MIXERS_PATH/$MIXER.mix ]
then
set MIXER_FILE $SDCARD_MIXERS_PATH/$MIXER.mix
else
set MIXER_FILE /etc/mixers/$MIXER.main.mix
fi
fi
if [ $OUTPUT_MODE == mkblctrl ]
then
2015-02-03 13:43:52 +01:00
set OUTPUT_DEV /dev/mkblctrl0
else
2015-02-03 13:43:52 +01:00
set OUTPUT_DEV /dev/pwm_output0
fi
if [ $OUTPUT_MODE == uavcan_esc ]
2014-05-08 14:23:33 +02:00
then
set OUTPUT_DEV /dev/uavcan/esc
2014-05-08 14:23:33 +02:00
fi
if mixer load $OUTPUT_DEV $MIXER_FILE
then
echo "[i] Mixer: $MIXER_FILE on $OUTPUT_DEV"
else
echo "[i] Error loading mixer: $MIXER_FILE"
echo "ERROR: Could not load mixer: $MIXER_FILE" >> $LOG_FILE
2014-11-17 14:56:11 +01:00
tone_alarm $TUNE_ERR
fi
2014-11-17 14:56:11 +01:00
unset MIXER_FILE
else
if [ $MIXER != skip ]
then
echo "[i] Mixer not defined"
echo "ERROR: Mixer not defined" >> $LOG_FILE
2014-11-17 14:56:11 +01:00
tone_alarm $TUNE_ERR
fi
fi
if [ $OUTPUT_MODE == fmu -o $OUTPUT_MODE == io ]
then
2014-11-17 14:56:11 +01:00
if [ $PWM_OUT != none ]
then
#
# Set PWM output frequency
#
if [ $PWM_RATE != none ]
then
2014-11-17 14:56:11 +01:00
pwm rate -c $PWM_OUT -r $PWM_RATE
fi
#
# Set disarmed, min and max PWM values
#
if [ $PWM_DISARMED != none ]
then
2014-11-17 14:56:11 +01:00
pwm disarmed -c $PWM_OUT -p $PWM_DISARMED
fi
if [ $PWM_MIN != none ]
then
2014-11-17 14:56:11 +01:00
pwm min -c $PWM_OUT -p $PWM_MIN
fi
if [ $PWM_MAX != none ]
then
2014-11-17 14:56:11 +01:00
pwm max -c $PWM_OUT -p $PWM_MAX
fi
fi
2014-08-26 10:13:52 +02:00
if [ $FAILSAFE != none ]
then
pwm failsafe -d $OUTPUT_DEV $FAILSAFE
fi
fi
# check if should load secondary mixer
if [ $MIXER_AUX != none ]
then
#
# Load aux mixer
#
set MIXER_AUX_FILE none
set OUTPUT_AUX_DEV /dev/pwm_output1
if [ -f $SDCARD_MIXERS_PATH/$MIXER_AUX.aux.mix ]
then
2015-04-20 17:05:59 +02:00
set MIXER_AUX_FILE $SDCARD_MIXERS_PATH/$MIXER_AUX.aux.mix
else
2015-04-20 17:05:59 +02:00
if [ -f /etc/mixers/$MIXER_AUX.aux.mix ]
then
2015-04-20 17:05:59 +02:00
set MIXER_AUX_FILE /etc/mixers/$MIXER_AUX.aux.mix
fi
fi
if [ $MIXER_AUX_FILE != none -a $FMU_MODE == pwm ]
then
if fmu mode_pwm
then
if mixer load $OUTPUT_AUX_DEV $MIXER_AUX_FILE
then
echo "[i] Mixer: $MIXER_AUX_FILE on $OUTPUT_AUX_DEV"
else
echo "[i] Error loading mixer: $MIXER_AUX_FILE"
echo "ERROR: Could not load mixer: $MIXER_AUX_FILE" >> $LOG_FILE
fi
else
echo "ERROR: Could not start: fmu mode_pwm" >> $LOG_FILE
tone_alarm $TUNE_ERR
fi
if [ $PWM_AUX_OUT != none ]
then
#
# Set PWM_AUX output frequency
#
if [ $PWM_AUX_RATE != none ]
then
pwm rate -c $PWM_AUX_OUT -r $PWM_AUX_RATE -d $OUTPUT_AUX_DEV
fi
#
# Set disarmed, min and max PWM_AUX values
#
if [ $PWM_AUX_DISARMED != none ]
then
pwm disarmed -c $PWM_AUX_OUT -p $PWM_AUX_DISARMED -d $OUTPUT_AUX_DEV
fi
if [ $PWM_AUX_MIN != none ]
then
pwm min -c $PWM_AUX_OUT -p $PWM_AUX_MIN -d $OUTPUT_AUX_DEV
fi
if [ $PWM_AUX_MAX != none ]
then
pwm max -c $PWM_AUX_OUT -p $PWM_AUX_MAX -d $OUTPUT_AUX_DEV
fi
fi
if [ $FAILSAFE_AUX != none ]
then
pwm failsafe -d $OUTPUT_AUX_DEV $FAILSAFE
fi
fi
fi
2015-01-08 15:42:25 +01:00
unset OUTPUT_DEV