Added better logging to actions.
Change-Id: Iaaadf5687afb8de7095378efbdb0f440a1059457
diff --git a/frc971/actions/action.h b/frc971/actions/action.h
index 1fc50ea..8884b7b 100644
--- a/frc971/actions/action.h
+++ b/frc971/actions/action.h
@@ -7,6 +7,7 @@
#include <functional>
#include "aos/common/logging/logging.h"
+#include "aos/common/logging/queue_logging.h"
#include "aos/common/time.h"
#include "frc971/constants.h"
@@ -26,15 +27,18 @@
action_q_->goal.FetchLatest();
if (action_q_->goal.get()) {
+ LOG_STRUCT(DEBUG, "goal queue ", *action_q_->goal);
const uint32_t initially_running = action_q_->goal->run;
if (initially_running != 0) {
while (action_q_->goal->run == initially_running) {
LOG(INFO, "run is still %" PRIx32 "\n", initially_running);
action_q_->goal.FetchNextBlocking();
+ LOG_STRUCT(DEBUG, "goal queue ", *action_q_->goal);
}
}
} else {
action_q_->goal.FetchNextBlocking();
+ LOG_STRUCT(DEBUG, "goal queue ", *action_q_->goal);
}
LOG(DEBUG, "actually starting\n");
@@ -46,6 +50,7 @@
while (!action_q_->goal->run) {
LOG(INFO, "Waiting for an action request.\n");
action_q_->goal.FetchNextBlocking();
+ LOG_STRUCT(DEBUG, "goal queue ", *action_q_->goal);
if (!action_q_->goal->run) {
if (!action_q_->status.MakeWithBuilder().running(0).Send()) {
LOG(ERROR, "Failed to send the status.\n");
@@ -75,6 +80,7 @@
LOG(INFO, "Waiting for the action (%" PRIx32 ") to be stopped.\n",
running_id);
action_q_->goal.FetchNextBlocking();
+ LOG_STRUCT(DEBUG, "goal queue ", *action_q_->goal);
}
LOG(DEBUG, "action %" PRIx32 " was stopped\n", running_id);
}
@@ -112,7 +118,9 @@
// Returns true if the action should be canceled.
bool ShouldCancel() {
- action_q_->goal.FetchLatest();
+ if (action_q_->goal.FetchNext()) {
+ LOG_STRUCT(DEBUG, "goal queue ", *action_q_->goal);
+ }
bool ans = !action_q_->goal->run;
if (ans) {
LOG(INFO, "Time to stop action\n");
diff --git a/frc971/actions/actions.gyp b/frc971/actions/actions.gyp
index 0ddd61c..813bdce 100644
--- a/frc971/actions/actions.gyp
+++ b/frc971/actions/actions.gyp
@@ -142,11 +142,13 @@
'<(AOS)/build/aos.gyp:logging',
'<(DEPTH)/frc971/frc971.gyp:constants',
'<(AOS)/common/common.gyp:time',
+ '<(AOS)/common/logging/logging.gyp:queue_logging',
],
'export_dependent_settings': [
'<(AOS)/build/aos.gyp:logging',
'<(DEPTH)/frc971/frc971.gyp:constants',
'<(AOS)/common/common.gyp:time',
+ '<(AOS)/common/logging/logging.gyp:queue_logging',
],
},
{