From: Joseph Coffland Date: Tue, 23 Aug 2016 06:23:04 +0000 (-0700) Subject: Roll back flush ID code, Skip some callbacks in EStop X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=f42fdffc60a9b418a119f9694ca74e1683be7337;p=bbctrl-firmware Roll back flush ID code, Skip some callbacks in EStop --- diff --git a/src/command.c b/src/command.c index bc38950..189b340 100644 --- a/src/command.c +++ b/src/command.c @@ -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; -} diff --git a/src/command.def b/src/command.def index ee7d4b2..03f5dca 100644 --- a/src/command.def +++ b/src/command.def @@ -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") diff --git a/src/i2c.c b/src/i2c.c index 2f2df66..0ec26b9 100644 --- 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 . diff --git a/src/i2c.h b/src/i2c.h index 9502ce4..4a833f0 100644 --- 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, diff --git a/src/machine.c b/src/machine.c index 5d93183..1162b6f 100644 --- a/src/machine.c +++ b/src/machine.c @@ -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(); diff --git a/src/machine.h b/src/machine.h index a8b9ebe..2b398b1 100644 --- a/src/machine.h +++ b/src/machine.h @@ -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(); diff --git a/src/main.c b/src/main.c index 3d38205..4f33b18 100644 --- a/src/main.c +++ b/src/main.c @@ -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();