/
rc.interface
252 lines (221 loc) · 5.03 KB
/
rc.interface
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#!nsh
#
# Script to configure control interface
#
#
# 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.
#
set SDCARD_MIXERS_PATH /fs/microsd/etc/mixers
if [ $MIXER != none -a $MIXER != skip ]
then
#
# Load main mixer
#
if [ $MIXER_AUX == none -a $USE_IO == yes ]
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/mkblctrl0
else
set OUTPUT_DEV /dev/pwm_output0
fi
if [ $OUTPUT_MODE == uavcan_esc ]
then
set OUTPUT_DEV /dev/uavcan/esc
fi
if [ $OUTPUT_MODE == tap_esc ]
then
set OUTPUT_DEV /dev/tap_esc
fi
if mixer load ${OUTPUT_DEV} ${MIXER_FILE}
then
echo "INFO [init] Mixer: ${MIXER_FILE} on ${OUTPUT_DEV}"
else
echo "ERROR [init] Failed loading mixer: ${MIXER_FILE}"
echo "ERROR [init] Failed loading mixer: ${MIXER_FILE}" >> $LOG_FILE
tone_alarm ${TUNE_ERR}
fi
unset MIXER_FILE
else
if [ $MIXER != skip ]
then
echo "ERROR [init] Mixer undefined"
echo "ERROR [init] Mixer undefined" >> $LOG_FILE
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
# This is a FMUv2+ thing
if ver hwcmp PX4FMU_V1
then
set MIXER_AUX none
fi
#MindPX has not aux mixer
if ver hwcmp MINDPX_V2
then
set MIXER_AUX none
fi
if ver hwcmp CRAZYFLIE
then
set MIXER_AUX none
fi
if ver hwcmp AEROFC_V1
then
set MIXER_AUX none
fi
if ver hwcmp PX4FMU_V5
then
set MIXER_AUX none
fi
if [ $MIXER_AUX != none -a $AUX_MODE != 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
set MIXER_AUX_FILE ${SDCARD_MIXERS_PATH}/${MIXER_AUX}.aux.mix
else
if [ -f /etc/mixers/${MIXER_AUX}.aux.mix ]
then
set MIXER_AUX_FILE /etc/mixers/${MIXER_AUX}.aux.mix
fi
fi
if [ $MIXER_AUX_FILE != none ]
then
if fmu mode_${AUX_MODE}
then
# Append aux mixer to main device
if [ $OUTPUT_MODE == hil ]
then
if mixer append ${OUTPUT_DEV} ${MIXER_AUX_FILE}
then
echo "INFO [init] Mixer: ${MIXER_AUX_FILE} appended to ${OUTPUT_DEV}"
else
echo "ERROR [init] Failed appending mixer: ${MIXER_AUX_FILE}"
echo "ERROR [init] Failed appending mixer: ${MIXER_AUX_FILE}" >> $LOG_FILE
fi
fi
if [ -e $OUTPUT_AUX_DEV -a $OUTPUT_MODE != hil ]
then
if mixer load ${OUTPUT_AUX_DEV} ${MIXER_AUX_FILE}
then
echo "INFO [init] Mixer: ${MIXER_AUX_FILE} on ${OUTPUT_AUX_DEV}"
else
echo "ERROR [init] Failed loading mixer: ${MIXER_AUX_FILE}"
echo "ERROR [init] Failed loading mixer: ${MIXER_AUX_FILE}" >> $LOG_FILE
fi
else
set PWM_AUX_OUT none
set FAILSAFE_AUX none
fi
else
echo "ERROR: Could not start: fmu mode_pwm" >> $LOG_FILE
tone_alarm ${TUNE_ERR}
set PWM_AUX_OUT none
set FAILSAFE_AUX none
fi
# Set min / max for aux out and rates
if [ $PWM_AUX_OUT != none ]
then
#
# Set PWM_AUX output frequency
#
if [ $PWM_AUX_RATE != none ]
then
pwm rate -e -c ${PWM_AUX_OUT} -r ${PWM_AUX_RATE} -d ${OUTPUT_AUX_DEV}
fi
if [ $PWM_AUX_MIN != none ]
then
pwm min -e -c ${PWM_AUX_OUT} -p ${PWM_AUX_MIN} -d ${OUTPUT_AUX_DEV}
fi
if [ $PWM_AUX_MAX != none ]
then
pwm max -e -c ${PWM_AUX_OUT} -p ${PWM_AUX_MAX} -d ${OUTPUT_AUX_DEV}
fi
fi
# 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
pwm disarmed -e -c ${PWM_ACHDIS} -p ${PWM_AUX_DISARMED} -d ${OUTPUT_AUX_DEV}
fi
if [ $FAILSAFE_AUX != none ]
then
pwm failsafe -e -d ${OUTPUT_AUX_DEV} ${FAILSAFE}
fi
fi
fi
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
unset OUTPUT_DEV
unset OUTPUT_AUX_DEV