aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-08-17 18:40:28 +0200
committerLorenz Meier <lm@inf.ethz.ch>2013-08-17 18:40:28 +0200
commiteda528157a04185cbb1342c152c4ac715f67771c (patch)
treee5d89f69ee4b446ea04f77f2b2112fe0c788556c
parente9b6cfd671c72b75f2bf79bf1031ea8697f430b2 (diff)
downloadpx4-firmware-eda528157a04185cbb1342c152c4ac715f67771c.tar.gz
px4-firmware-eda528157a04185cbb1342c152c4ac715f67771c.tar.bz2
px4-firmware-eda528157a04185cbb1342c152c4ac715f67771c.zip
Make state updates atomic (just to be really, really sure)
-rw-r--r--src/modules/commander/state_machine_helper.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/modules/commander/state_machine_helper.cpp b/src/modules/commander/state_machine_helper.cpp
index ef3890b71..5842a33b1 100644
--- a/src/modules/commander/state_machine_helper.cpp
+++ b/src/modules/commander/state_machine_helper.cpp
@@ -69,6 +69,11 @@ static bool navigation_state_changed = true;
transition_result_t
arming_state_transition(struct vehicle_status_s *status, const struct safety_s *safety, arming_state_t new_arming_state, struct actuator_armed_s *armed)
{
+ /*
+ * Perform an atomic state update
+ */
+ irqstate_t flags = irqsave();
+
transition_result_t ret = TRANSITION_DENIED;
/* only check transition if the new state is actually different from the current one */
@@ -168,11 +173,15 @@ arming_state_transition(struct vehicle_status_s *status, const struct safety_s *
if (ret == TRANSITION_CHANGED) {
status->arming_state = new_arming_state;
arming_state_changed = true;
- } else {
- warnx("arming transition rejected");
}
}
+ /* end of atomic state update */
+ irqrestore(flags);
+
+ if (ret == TRANSITION_DENIED)
+ warnx("arming transition rejected");
+
return ret;
}