Skip to content

Commit 75ad726

Browse files
andyp1perpeterbarker
authored andcommitted
Copter: fix threading issues with motor test and the fast rate thread
1 parent dd5af39 commit 75ad726

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

ArduCopter/motor_test.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,9 @@ MAV_RESULT Copter::mavlink_motor_test_start(const GCS_MAVLINK &gcs_chan, uint8_t
159159
} else {
160160
// start test
161161
gcs().send_text(MAV_SEVERITY_INFO, "starting motor test");
162-
ap.motor_test = true;
163162

164163
EXPECT_DELAY_MS(3000);
165164

166-
// wait for rate thread to stop running due to motor test
167-
while (using_rate_thread) {
168-
hal.scheduler->delay(1);
169-
}
170-
171165
// enable and arm motors
172166
if (!motors->armed()) {
173167
motors->output_min(); // output lowest possible value to motors
@@ -182,6 +176,7 @@ MAV_RESULT Copter::mavlink_motor_test_start(const GCS_MAVLINK &gcs_chan, uint8_t
182176

183177
// turn on notify leds
184178
AP_Notify::flags.esc_calibration = true;
179+
ap.motor_test = true;
185180
}
186181
}
187182

@@ -213,9 +208,6 @@ void Copter::motor_test_stop()
213208

214209
gcs().send_text(MAV_SEVERITY_INFO, "finished motor test");
215210

216-
// flag test is complete
217-
ap.motor_test = false;
218-
219211
// disarm motors
220212
motors->armed(false);
221213
hal.util->set_soft_armed(false);
@@ -235,4 +227,7 @@ void Copter::motor_test_stop()
235227

236228
// turn off notify leds
237229
AP_Notify::flags.esc_calibration = false;
230+
231+
// flag test is complete
232+
ap.motor_test = false;
238233
}

ArduCopter/rate_thread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void Copter::rate_controller_thread()
215215
#endif
216216

217217
// allow changing option at runtime
218-
if (get_fast_rate_type() == FastRateType::FAST_RATE_DISABLED || ap.motor_test) {
218+
if (get_fast_rate_type() == FastRateType::FAST_RATE_DISABLED) {
219219
if (was_using_rate_thread) {
220220
disable_fast_rate_loop(rates);
221221
was_using_rate_thread = false;

0 commit comments

Comments
 (0)