From 9ee19a4d7c2abfcf73001c391687250961597337 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sun, 24 Mar 2013 00:15:58 +0100 Subject: digital/io-hub/src/apbirthday: add FSM debug --- digital/io-hub/src/apbirthday/robot.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'digital/io-hub/src/apbirthday/robot.cc') diff --git a/digital/io-hub/src/apbirthday/robot.cc b/digital/io-hub/src/apbirthday/robot.cc index 25ea7059..2dc3de95 100644 --- a/digital/io-hub/src/apbirthday/robot.cc +++ b/digital/io-hub/src/apbirthday/robot.cc @@ -37,6 +37,7 @@ Robot::Robot () zb_proto (*this, hardware.zb_uart), usb_proto (*this, hardware.usb), chrono (90000 - 1000), + fsm_debug_state_ (FSM_DEBUG_RUN), outputs_set_ (outputs_, lengthof (outputs_)), stats_proto_ (0), stats_chrono_ (false), stats_chrono_last_s_ (-1), @@ -92,8 +93,12 @@ Robot::main_loop () // Handle communications. bool sync = main_i2c_queue_.sync (); // Handle events if synchronised. - if (sync) - fsm_gen_event (); + if (sync && fsm_debug_state_ != FSM_DEBUG_STOP) + { + if (fsm_gen_event () + && fsm_debug_state_ == FSM_DEBUG_STEP) + fsm_debug_state_ = FSM_DEBUG_STOP; + } // Handle commands. dev_proto.accept (); zb_proto.accept (); @@ -147,6 +152,10 @@ Robot::proto_handle (ucoo::Proto &proto, char cmd, const uint8_t *args, int size // Reset. ucoo::arch_reset (); break; + case c ('f', 0): + // Enter FSM debug mode, then step once. + fsm_debug_state_ = FSM_DEBUG_STEP; + break; case c ('m', 5): // Go to position. // 2H: x, y. -- cgit v1.2.3