aboutsummaryrefslogtreecommitdiff
path: root/ROMFS/px4fmu_common/init.d/rc.interface
blob: 7fde482df7359545d2506477fa7e91f3c9eeeabe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!nsh
#
# Script to configure control interface
#

set SDCARD_MIXERS_PATH /fs/microsd/etc/mixers

if [ $MIXER != none -a $MIXER != skip ]
then
	#
	# Load main mixer
	#

	if [ $MIXER_AUX == none ]
	then
		set MIXER_AUX $MIXER.aux
	fi

	# 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
		set OUTPUT_DEV /dev/mkblctrl
	else
		set OUTPUT_DEV /dev/pwm_output
	fi

	if [ $OUTPUT_MODE == uavcan_esc ]
	then
		set OUTPUT_DEV /dev/uavcan/esc
	fi

	if mixer load $OUTPUT_DEV $MIXER_FILE
	then
		echo "[i] Mixer: $MIXER_FILE"
	else
		echo "[i] Error loading mixer: $MIXER_FILE"
		tone_alarm $TUNE_ERR
	fi

	unset MIXER_FILE
else
	if [ $MIXER != skip ]
	then
		echo "[i] Mixer not defined"
		tone_alarm $TUNE_ERR
	fi
fi

if [ $OUTPUT_MODE == fmu -o $OUTPUT_MODE == io ]
then
	if [ $PWM_OUT != none ]
	then
		#
		# Set PWM output frequency
		#
		if [ $PWM_RATE != none ]
		then
			pwm rate -c $PWM_OUT -r $PWM_RATE
		fi

		#
		# Set disarmed, min and max PWM values
		#
		if [ $PWM_DISARMED != none ]
		then
			pwm disarmed -c $PWM_OUT -p $PWM_DISARMED
		fi
		if [ $PWM_MIN != none ]
		then
			pwm min -c $PWM_OUT -p $PWM_MIN
		fi
		if [ $PWM_MAX != none ]
		then
			pwm max -c $PWM_OUT -p $PWM_MAX
		fi
	fi

	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

	if [ -f $SDCARD_MIXERS_PATH/$MIXER_AUX.mix ]
	then
		set MIXER_AUX_FILE $SDCARD_MIXERS_PATH/$MIXER_AUX.mix
	else

		if [ -f /etc/mixers/$MIXER_AUX.mix ]
		then
			set MIXER_AUX_FILE /etc/mixers/$MIXER_AUX.mix
		fi
	fi

	if [ $MIXER_AUX_FILE != none -a $FMU_MODE == pwm ]
	then
		if fmu mode_pwm
		then
			mixer load /dev/pwm_output1 $MIXER_AUX_FILE
		else
			tone_alarm $TUNE_ERR
		fi
	fi
fi
unset OUTPUT_DEV