Roll back flush ID code, Skip some callbacks in EStop
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 23 Aug 2016 06:23:04 +0000 (23:23 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 23 Aug 2016 06:23:04 +0000 (23:23 -0700)
src/command.c
src/command.def
src/i2c.c
src/i2c.h
src/machine.c
src/machine.h
src/main.c

index bc389504d6f84ebf2ba41b9fec1e15a7bbcd6841..189b3402c3ca93bebc60054cc1784257d9ecad58 100644 (file)
@@ -58,8 +58,7 @@ static void _estop()  {estop_trigger(ESTOP_USER);}
 static void _clear()  {estop_clear();}
 static void _pause()  {mach_request_feedhold();}
 static void _run()    {mach_request_cycle_start();}
-static void _flush(uint16_t id) {mach_request_queue_flush(id);}
-static void _step()   {}
+static void _step()   {} // TODO
 static void _report() {report_request_full();}
 static void _reboot() {hw_request_hard_reset();}
 
@@ -70,7 +69,6 @@ static void command_i2c_cb(i2c_cmd_t cmd, uint8_t *data, uint8_t length) {
   case I2C_CLEAR:  _clear();  break;
   case I2C_PAUSE:  _pause();  break;
   case I2C_RUN:    _run();    break;
-  case I2C_FLUSH:  _flush(*(uint16_t *)data);  break;
   case I2C_STEP:   _step();   break;
   case I2C_REPORT: _report(); break;
   case I2C_HOME: break;
@@ -314,27 +312,3 @@ uint8_t command_messages(int argc, char *argv[]) {
   status_help();
   return 0;
 }
-
-
-uint8_t command_sync(int argc, char *argv[]) {
-  char *end = 0;
-  uint32_t x = strtoul(argv[1], &end, 0);
-
-  if (end) printf_P(PSTR("\n{\"sync\": %lu}\n"), x);
-  return 0;
-}
-
-
-uint8_t command_end_flush(int argc, char *argv[]) {
-  uint16_t id = 0;
-  char *end = 0;
-
-  if (argc == 2) {
-    id = strtoul(argv[1], &end, 0);
-    if (!end) return STAT_BAD_NUMBER_FORMAT;
-  }
-
-  mach_end_queue_flush(id);
-
-  return 0;
-}
index ee7d4b266aebdda904099e8608e0b1a2b23fe83c..03f5dcadefb5c857fa2080b3e5cf0faf3fa3a139 100644 (file)
@@ -37,5 +37,3 @@ CMD(jog,          1, 4, "Jog")
 CMD(mreset,       0, 1, "Reset motor")
 CMD(calibrate,    0, 0, "Calibrate motors")
 CMD(messages,     0, 0, "Dump all possible status messages")
-CMD(sync,         1, 1, "Synchronize with queue processing")
-CMD(end_flush,    0, 1, "End a flush request, with optional ID")
index 2f2df66322e75257c08fb1bc1a39e742af8258d3..0ec26b990f2a9a0a7d77d6196c07c3d4455230f9 100644 (file)
--- a/src/i2c.c
+++ b/src/i2c.c
@@ -16,7 +16,7 @@
           WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                Lesser General Public License for more details.
-\
+
        You should have received a copy of the GNU Lesser General Public
                 License along with the software.  If not, see
                        <http://www.gnu.org/licenses/>.
index 9502ce47fc4e9d0ef528e712288b9ad4fab5d073..4a833f089ac4ff99aba80ea557fbb66e3104c4d1 100644 (file)
--- a/src/i2c.h
+++ b/src/i2c.h
@@ -40,7 +40,6 @@ typedef enum {
   I2C_PAUSE,
   I2C_OPTIONAL_PAUSE,
   I2C_RUN,
-  I2C_FLUSH,
   I2C_STEP,
   I2C_REPORT,
   I2C_HOME,
index 5d9318356b972e1256bb9aa6404b242b8a92d0b1..1162b6f26f831e34a74b849b74c6891187e722b4 100644 (file)
@@ -1118,33 +1118,14 @@ void mach_message(const char *message) {
  */
 
 
-/// Initiate a feedhold right now
 void mach_request_feedhold() {mach.feedhold_requested = true;}
-
-
-void mach_request_queue_flush(uint16_t id) {
-  if (!id) mach.queue_flush_id = 0;
-  mach.queue_flush_request = id;
-}
-
-
-void mach_end_queue_flush(uint16_t id) {
-  if (mach.queue_flush_request) mach.queue_flush_id = id;
-}
-
-
-bool mach_queue_flushing() {
-  return mach.queue_flush_request &&
-    (int16_t)(mach.queue_flush_id - mach.queue_flush_request) < 0;
-}
-
-
+void mach_request_queue_flush() {mach.queue_flush_requested = true;}
 void mach_request_cycle_start() {mach.cycle_start_requested = true;}
 
 
 /// Process feedholds, cycle starts & queue flushes
 void mach_feedhold_callback() {
-  if (mach.feedhold_requested || mach_queue_flushing()) {
+  if (mach.feedhold_requested) {
     if (mach.motion_state == MOTION_RUN && mach.hold_state == FEEDHOLD_OFF) {
       mach_set_motion_state(MOTION_HOLD);
       mach.hold_state = FEEDHOLD_SYNC; // invokes hold from aline execution
@@ -1153,18 +1134,21 @@ void mach_feedhold_callback() {
     mach.feedhold_requested = false;
   }
 
-  if (mach_queue_flushing() &&
+  if (mach.queue_flush_requested &&
       (mach.motion_state == MOTION_STOP ||
        (mach.motion_state == MOTION_HOLD &&
         mach.hold_state == FEEDHOLD_HOLD)) &&
-      !mach_get_runtime_busy()) mach_queue_flush();
+      !mach_get_runtime_busy()) {
+    mach_queue_flush();
+    mach.queue_flush_requested = false;
+  }
 
   bool processing =
     mach.hold_state == FEEDHOLD_SYNC ||
     mach.hold_state == FEEDHOLD_PLAN ||
     mach.hold_state == FEEDHOLD_DECEL;
 
-  if (mach.cycle_start_requested && !mach_queue_flushing() && !processing) {
+  if (mach.cycle_start_requested && !processing) {
     mach.cycle_start_requested = false;
     mach.hold_state = FEEDHOLD_END_HOLD;
     mach_cycle_start();
index a8b9ebeced4ad0bf0d5d28feafe76e09a378df5b..2b398b152e6c5312273c6417c58777226cf5bbc6 100644 (file)
@@ -397,8 +397,7 @@ typedef struct { // struct to manage mach globals and cycles
   float probe_results[AXES];           // probing results
 
   bool feedhold_requested;
-  uint16_t queue_flush_request;        // queue flush request id
-  uint16_t queue_flush_id;             // latest queue flush request id
+  bool queue_flush_requested;
   bool cycle_start_requested;
 
   // Model states
@@ -525,8 +524,7 @@ void mach_message(const char *message);
 
 // Program Functions (4.3.10)
 void mach_request_feedhold();
-void mach_request_queue_flush(uint16_t id);
-void mach_end_queue_flush(uint16_t id);
+void mach_request_queue_flush();
 void mach_request_cycle_start();
 
 void mach_feedhold_callback();
index 3d38205756cf222ef66c23b82672aa645fd2a00f..4f33b1800cd608eb35d54a37b6cd01eff46f8d2c 100644 (file)
@@ -82,10 +82,12 @@ int main() {
   // Main loop
   while (true) {
     hw_reset_handler();           // handle hard reset requests
-    mach_feedhold_callback();     // feedhold state machine
-    mach_arc_callback();          // arc generation runs
-    mach_homing_callback();       // G28.2 continuation
-    mach_probe_callback();        // G38.2 continuation
+    if (!estop_triggered()) {
+      mach_feedhold_callback();     // feedhold state machine
+      mach_arc_callback();          // arc generation runs
+      mach_homing_callback();       // G28.2 continuation
+      mach_probe_callback();        // G38.2 continuation
+    }
     command_callback();           // process next command
     report_callback();            // report changes
     wdt_reset();