2014-01-15 00:02:57 +01:00
|
|
|
#!nsh
|
|
|
|
|
#
|
|
|
|
|
# Script to configure control interface
|
|
|
|
|
#
|
2016-12-12 14:24:01 -10:00
|
|
|
#
|
|
|
|
|
# NOTE: environment variable references:
|
|
|
|
|
# If the dollar sign ('$') is followed by a left bracket ('{') then the
|
|
|
|
|
# variable name is terminated with the right bracket character ('}').
|
|
|
|
|
# Otherwise, the variable name goes to the end of the argument.
|
|
|
|
|
#
|
2014-01-15 00:02:57 +01:00
|
|
|
|
2015-01-07 00:25:06 +02:00
|
|
|
set SDCARD_MIXERS_PATH /fs/microsd/etc/mixers
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2014-03-06 23:11:13 +01:00
|
|
|
if [ $MIXER != none -a $MIXER != skip ]
|
2014-01-15 00:02:57 +01:00
|
|
|
then
|
|
|
|
|
#
|
2015-01-07 00:25:06 +02:00
|
|
|
# Load main mixer
|
2014-01-15 00:02:57 +01:00
|
|
|
#
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2015-03-01 20:14:41 -08:00
|
|
|
if [ $MIXER_AUX == none -a $USE_IO == yes ]
|
2015-01-08 12:55:28 +02:00
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
set MIXER_AUX ${MIXER}.aux
|
2015-01-08 12:55:28 +02:00
|
|
|
fi
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2015-01-06 19:53:52 +01:00
|
|
|
# Use the mixer file from the SD-card if it exists
|
2016-12-12 14:24:01 -10:00
|
|
|
if [ -f ${SDCARD_MIXERS_PATH}/${MIXER}.main.mix ]
|
2014-01-15 00:02:57 +01:00
|
|
|
then
|
2016-12-12 14:24:01 -10:00
|
|
|
set MIXER_FILE ${SDCARD_MIXERS_PATH}/${MIXER}.main.mix
|
2015-01-07 00:25:06 +02:00
|
|
|
# Try out the old convention, for backward compatibility
|
2015-01-08 12:55:28 +02:00
|
|
|
else
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2016-12-12 14:24:01 -10:00
|
|
|
if [ -f ${SDCARD_MIXERS_PATH}/${MIXER}.mix ]
|
2015-01-08 12:55:28 +02:00
|
|
|
then
|
2016-12-12 14:24:01 -10:00
|
|
|
set MIXER_FILE ${SDCARD_MIXERS_PATH}/${MIXER}.mix
|
2015-01-08 12:55:28 +02:00
|
|
|
else
|
2016-12-12 14:24:01 -10:00
|
|
|
set MIXER_FILE /etc/mixers/${MIXER}.main.mix
|
2015-01-08 12:55:28 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2016-11-16 15:45:33 -02:00
|
|
|
if [ $OUTPUT_MODE == mkblctrl ]
|
2014-01-15 00:02:57 +01:00
|
|
|
then
|
2016-11-16 15:45:33 -02:00
|
|
|
set OUTPUT_DEV /dev/mkblctrl0
|
2014-01-15 00:02:57 +01:00
|
|
|
else
|
2016-11-16 15:45:33 -02:00
|
|
|
set OUTPUT_DEV /dev/pwm_output0
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2014-07-07 02:31:05 +04:00
|
|
|
if [ $OUTPUT_MODE == uavcan_esc ]
|
2014-05-08 14:23:33 +02:00
|
|
|
then
|
2014-05-08 17:03:40 +04:00
|
|
|
set OUTPUT_DEV /dev/uavcan/esc
|
2014-05-08 14:23:33 +02:00
|
|
|
fi
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2016-11-16 15:45:33 -02:00
|
|
|
if [ $OUTPUT_MODE == tap_esc ]
|
|
|
|
|
then
|
|
|
|
|
set OUTPUT_DEV /dev/tap_esc
|
|
|
|
|
fi
|
|
|
|
|
|
2016-12-23 09:06:49 +01:00
|
|
|
if mixer load ${OUTPUT_DEV} ${MIXER_FILE}
|
2014-01-15 00:02:57 +01:00
|
|
|
then
|
2016-12-13 13:21:01 +01:00
|
|
|
echo "INFO [init] Mixer: ${MIXER_FILE} on ${OUTPUT_DEV}"
|
2014-01-15 00:02:57 +01:00
|
|
|
else
|
2016-12-13 13:21:01 +01:00
|
|
|
echo "ERROR [init] Failed loading mixer: ${MIXER_FILE}"
|
|
|
|
|
echo "ERROR [init] Failed loading mixer: ${MIXER_FILE}" >> $LOG_FILE
|
2016-12-23 09:06:49 +01:00
|
|
|
tone_alarm ${TUNE_ERR}
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
2014-11-17 14:56:11 +01:00
|
|
|
|
|
|
|
|
unset MIXER_FILE
|
2014-01-15 00:02:57 +01:00
|
|
|
else
|
2014-03-06 12:45:10 +01:00
|
|
|
if [ $MIXER != skip ]
|
|
|
|
|
then
|
2016-12-13 13:21:01 +01:00
|
|
|
echo "ERROR [init] Mixer undefined"
|
|
|
|
|
echo "ERROR [init] Mixer undefined" >> $LOG_FILE
|
2016-12-23 09:06:49 +01:00
|
|
|
tone_alarm ${TUNE_ERR}
|
2014-03-06 12:45:10 +01:00
|
|
|
fi
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $OUTPUT_MODE == fmu -o $OUTPUT_MODE == io ]
|
|
|
|
|
then
|
2014-11-17 14:56:11 +01:00
|
|
|
if [ $PWM_OUT != none ]
|
2014-01-15 00:02:57 +01:00
|
|
|
then
|
|
|
|
|
#
|
|
|
|
|
# Set PWM output frequency
|
|
|
|
|
#
|
|
|
|
|
if [ $PWM_RATE != none ]
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
pwm rate -c ${PWM_OUT} -r ${PWM_RATE}
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2014-01-15 00:02:57 +01:00
|
|
|
#
|
|
|
|
|
# Set disarmed, min and max PWM values
|
|
|
|
|
#
|
|
|
|
|
if [ $PWM_DISARMED != none ]
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
pwm disarmed -c ${PWM_OUT} -p ${PWM_DISARMED}
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
|
|
|
|
if [ $PWM_MIN != none ]
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
pwm min -c ${PWM_OUT} -p ${PWM_MIN}
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
|
|
|
|
if [ $PWM_MAX != none ]
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
pwm max -c ${PWM_OUT} -p ${PWM_MAX}
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
|
|
|
|
fi
|
2014-08-26 10:13:52 +02:00
|
|
|
|
|
|
|
|
if [ $FAILSAFE != none ]
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
pwm failsafe -d ${OUTPUT_DEV} ${FAILSAFE}
|
2014-08-26 10:13:52 +02:00
|
|
|
fi
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
2015-01-08 12:55:28 +02:00
|
|
|
|
2015-08-11 09:45:49 +02:00
|
|
|
# This is a FMUv2+ thing
|
|
|
|
|
if ver hwcmp PX4FMU_V1
|
|
|
|
|
then
|
|
|
|
|
set MIXER_AUX none
|
|
|
|
|
fi
|
|
|
|
|
|
2016-03-12 12:50:14 +08:00
|
|
|
#MindPX has not aux mixer
|
|
|
|
|
if ver hwcmp MINDPX_V2
|
|
|
|
|
then
|
|
|
|
|
set MIXER_AUX none
|
|
|
|
|
fi
|
|
|
|
|
|
2016-08-20 21:04:42 -04:00
|
|
|
if ver hwcmp CRAZYFLIE
|
|
|
|
|
then
|
|
|
|
|
set MIXER_AUX none
|
|
|
|
|
fi
|
|
|
|
|
|
2016-09-21 14:20:31 -03:00
|
|
|
if ver hwcmp AEROFC_V1
|
|
|
|
|
then
|
|
|
|
|
set MIXER_AUX none
|
|
|
|
|
fi
|
|
|
|
|
|
2016-12-23 18:42:00 +01:00
|
|
|
if ver hwcmp PX4FMU_V5
|
|
|
|
|
then
|
|
|
|
|
set MIXER_AUX none
|
|
|
|
|
fi
|
|
|
|
|
|
2015-08-13 11:40:14 +02:00
|
|
|
if [ $MIXER_AUX != none -a $AUX_MODE != none ]
|
2015-01-06 16:30:47 +01:00
|
|
|
then
|
2015-01-08 12:55:28 +02:00
|
|
|
#
|
|
|
|
|
# Load aux mixer
|
|
|
|
|
#
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2015-01-08 12:55:28 +02:00
|
|
|
set MIXER_AUX_FILE none
|
2015-08-06 00:12:14 +02:00
|
|
|
set OUTPUT_AUX_DEV /dev/pwm_output1
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2016-12-12 14:24:01 -10:00
|
|
|
if [ -f ${SDCARD_MIXERS_PATH}/${MIXER_AUX}.aux.mix ]
|
2015-01-08 12:55:28 +02:00
|
|
|
then
|
2016-12-12 14:24:01 -10:00
|
|
|
set MIXER_AUX_FILE ${SDCARD_MIXERS_PATH}/${MIXER_AUX}.aux.mix
|
2015-01-08 12:55:28 +02:00
|
|
|
else
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2016-12-12 14:24:01 -10:00
|
|
|
if [ -f /etc/mixers/${MIXER_AUX}.aux.mix ]
|
2015-01-08 12:55:28 +02:00
|
|
|
then
|
2016-12-12 14:24:01 -10:00
|
|
|
set MIXER_AUX_FILE /etc/mixers/${MIXER_AUX}.aux.mix
|
2015-01-08 12:55:28 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
2015-01-08 13:35:02 +02:00
|
|
|
|
2015-08-13 09:45:33 +02:00
|
|
|
if [ $MIXER_AUX_FILE != none ]
|
2015-01-08 12:55:28 +02:00
|
|
|
then
|
2016-12-09 12:52:51 -10:00
|
|
|
if fmu mode_${AUX_MODE}
|
2015-01-08 12:55:28 +02:00
|
|
|
then
|
2016-09-07 12:09:22 +02:00
|
|
|
# Append aux mixer to main device
|
|
|
|
|
if [ $OUTPUT_MODE == hil ]
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
if mixer append ${OUTPUT_DEV} ${MIXER_AUX_FILE}
|
2016-09-07 12:09:22 +02:00
|
|
|
then
|
2016-12-13 13:21:01 +01:00
|
|
|
echo "INFO [init] Mixer: ${MIXER_AUX_FILE} appended to ${OUTPUT_DEV}"
|
2016-09-07 12:09:22 +02:00
|
|
|
else
|
2016-12-13 13:21:01 +01:00
|
|
|
echo "ERROR [init] Failed appending mixer: ${MIXER_AUX_FILE}"
|
|
|
|
|
echo "ERROR [init] Failed appending mixer: ${MIXER_AUX_FILE}" >> $LOG_FILE
|
2016-09-07 12:09:22 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
if [ -e $OUTPUT_AUX_DEV -a $OUTPUT_MODE != hil ]
|
2015-04-21 12:35:35 +02:00
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
if mixer load ${OUTPUT_AUX_DEV} ${MIXER_AUX_FILE}
|
2015-08-06 00:12:14 +02:00
|
|
|
then
|
2016-12-13 13:21:01 +01:00
|
|
|
echo "INFO [init] Mixer: ${MIXER_AUX_FILE} on ${OUTPUT_AUX_DEV}"
|
2015-08-06 00:12:14 +02:00
|
|
|
else
|
2016-12-13 13:21:01 +01:00
|
|
|
echo "ERROR [init] Failed loading mixer: ${MIXER_AUX_FILE}"
|
|
|
|
|
echo "ERROR [init] Failed loading mixer: ${MIXER_AUX_FILE}" >> $LOG_FILE
|
2015-08-06 00:12:14 +02:00
|
|
|
fi
|
2015-04-21 12:35:35 +02:00
|
|
|
else
|
2015-08-06 00:12:14 +02:00
|
|
|
set PWM_AUX_OUT none
|
|
|
|
|
set FAILSAFE_AUX none
|
2015-04-21 12:35:35 +02:00
|
|
|
fi
|
2015-01-08 12:55:28 +02:00
|
|
|
else
|
2015-05-07 10:17:56 +02:00
|
|
|
echo "ERROR: Could not start: fmu mode_pwm" >> $LOG_FILE
|
2016-12-23 09:06:49 +01:00
|
|
|
tone_alarm ${TUNE_ERR}
|
2015-08-06 00:12:14 +02:00
|
|
|
set PWM_AUX_OUT none
|
|
|
|
|
set FAILSAFE_AUX none
|
2015-01-08 12:55:28 +02:00
|
|
|
fi
|
2015-03-03 23:53:48 -08:00
|
|
|
|
2016-02-14 19:51:43 +01:00
|
|
|
# Set min / max for aux out and rates
|
2015-03-03 23:53:48 -08:00
|
|
|
if [ $PWM_AUX_OUT != none ]
|
|
|
|
|
then
|
|
|
|
|
#
|
|
|
|
|
# Set PWM_AUX output frequency
|
|
|
|
|
#
|
|
|
|
|
if [ $PWM_AUX_RATE != none ]
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
pwm rate -c ${PWM_AUX_OUT} -r ${PWM_AUX_RATE} -d ${OUTPUT_AUX_DEV}
|
2015-03-03 23:53:48 -08:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $PWM_AUX_MIN != none ]
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
pwm min -c ${PWM_AUX_OUT} -p ${PWM_AUX_MIN} -d ${OUTPUT_AUX_DEV}
|
2015-03-03 23:53:48 -08:00
|
|
|
fi
|
|
|
|
|
if [ $PWM_AUX_MAX != none ]
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
pwm max -c ${PWM_AUX_OUT} -p ${PWM_AUX_MAX} -d ${OUTPUT_AUX_DEV}
|
2015-03-03 23:53:48 -08:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2016-02-14 19:51:43 +01:00
|
|
|
# Set disarmed values for aux out
|
|
|
|
|
|
|
|
|
|
# Transitional support until all configs
|
|
|
|
|
# are updated
|
|
|
|
|
if [ $PWM_ACHDIS == none ]
|
|
|
|
|
then
|
|
|
|
|
set PWM_ACHDIS ${PWM_AUX_OUT}
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Set disarmed, min and max PWM_AUX values
|
|
|
|
|
#
|
|
|
|
|
if [ $PWM_AUX_DISARMED != none -a $PWM_ACHDIS != none ]
|
|
|
|
|
then
|
2016-12-12 09:07:15 +01:00
|
|
|
pwm disarmed -c ${PWM_ACHDIS} -p ${PWM_AUX_DISARMED} -d ${OUTPUT_AUX_DEV}
|
2016-02-14 19:51:43 +01:00
|
|
|
fi
|
|
|
|
|
|
2015-03-03 23:53:48 -08:00
|
|
|
if [ $FAILSAFE_AUX != none ]
|
|
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
pwm failsafe -d ${OUTPUT_AUX_DEV} ${FAILSAFE}
|
2015-03-03 23:53:48 -08:00
|
|
|
fi
|
|
|
|
|
|
2015-01-08 12:55:28 +02:00
|
|
|
fi
|
2015-01-08 13:35:02 +02:00
|
|
|
fi
|
2016-03-28 14:48:14 +02:00
|
|
|
|
|
|
|
|
unset PWM_OUT
|
|
|
|
|
unset PWM_RATE
|
|
|
|
|
unset PWM_ACHDIS
|
|
|
|
|
unset PWM_MIN
|
|
|
|
|
unset PWM_MAX
|
|
|
|
|
unset PWM_AUX_OUT
|
|
|
|
|
unset PWM_AUX_RATE
|
|
|
|
|
unset PWM_AUX_DISARMED
|
|
|
|
|
unset PWM_AUX_MIN
|
|
|
|
|
unset PWM_AUX_MAX
|
|
|
|
|
unset FAILSAFE_AUX
|
|
|
|
|
unset FAILSAFE
|
2015-01-08 15:42:25 +01:00
|
|
|
unset OUTPUT_DEV
|
2015-08-04 23:26:54 +02:00
|
|
|
unset OUTPUT_AUX_DEV
|