diff --git a/g2core/alarm.cpp b/g2core/alarm.cpp
index 99345a21..dc9c0e0f 100644
--- a/g2core/alarm.cpp
+++ b/g2core/alarm.cpp
@@ -249,3 +249,18 @@ stat_t cm_panic(const stat_t status, const char *msg)
rpt_exception(status, msg); // send panic report
return (status);
}
+
+/****************************************************************************************
+ * cm_job_kill() - Control-D handler
+ */
+
+void cm_job_kill()
+{
+ cm->job_kill_requested = true;
+
+ if (cm->machine_state == MACHINE_ALARM) {
+ cm->machine_state = MACHINE_PROGRAM_STOP;
+ } else if (cm->machine_state == MACHINE_SHUTDOWN) {
+ cm->machine_state = MACHINE_READY;
+ }
+}
diff --git a/g2core/canonical_machine.h b/g2core/canonical_machine.h
index e5e2978f..a5e49b4f 100644
--- a/g2core/canonical_machine.h
+++ b/g2core/canonical_machine.h
@@ -260,6 +260,7 @@ typedef struct cmMachine { // struct to manage canonical machin
uint8_t shutdown_requested; // set non-zero to request shutdown in support of external estop (value is input number)
bool deferred_write_flag; // G10 data has changed (e.g. offsets) - flag to persist them
bool hold_exit_requested; // request exit from feedhold
+ bool job_kill_requested; // ^d job kill received
bool return_flags[AXES]; // flags for recording which axes moved - used in feedhold exit move
cmHomingState homing_state; // home: homing cycle sub-state machine
@@ -477,6 +478,7 @@ void cm_halt_motion(void); // halt motion (
stat_t cm_alarm(const stat_t status, const char *msg); // enter alarm state - preserve Gcode state
stat_t cm_shutdown(const stat_t status, const char *msg); // enter shutdown state - dump all state
stat_t cm_panic(const stat_t status, const char *msg); // enter panic state - needs RESET
+void cm_job_kill(void); // control-D handler
/**** cfgArray interface functions ****/
diff --git a/g2core/controller.cpp b/g2core/controller.cpp
index 3d853648..4cda51d9 100644
--- a/g2core/controller.cpp
+++ b/g2core/controller.cpp
@@ -239,7 +239,7 @@ static void _dispatch_kernel(const devflags_t flags)
if (*cs.bufp == '!') { cm_request_feedhold(); }
else if (*cs.bufp == '%') { cm_request_queue_flush(); xio_flush_to_command(); }
else if (*cs.bufp == '~') { cm_request_exit_hold(); }
- else if (*cs.bufp == EOT) { cm_alarm(STAT_KILL_JOB, "EOT Received"); }
+ else if (*cs.bufp == EOT) { cm_job_kill(); }
else if (*cs.bufp == ENQ) { controller_request_enquiry(); }
else if (*cs.bufp == CAN) { hw_hard_reset(); } // reset immediately
diff --git a/g2core/g2core.cppproj b/g2core/g2core.cppproj
index 95da67f1..0014b2ec 100644
--- a/g2core/g2core.cppproj
+++ b/g2core/g2core.cppproj
@@ -73,7 +73,7 @@
SWD
com.atmel.avrdbg.tool.atmelice
- J41800019454
+ J41800036434
Atmel-ICE
True
@@ -100,7 +100,7 @@
True
true
- J41800019454
+ J41800036434
0x284E0A60
10000000
diff --git a/g2core/plan_exec.cpp b/g2core/plan_exec.cpp
index c1f40e3f..54f4cc77 100644
--- a/g2core/plan_exec.cpp
+++ b/g2core/plan_exec.cpp
@@ -240,6 +240,13 @@ stat_t mp_exec_move()
{
mpBuf_t *bf;
+ // It is possible to try to try to exec from a priming planner if coming off a hold
+ // This occurs if new p1 commands (and were held back) arrived while in a hold
+// if (mp->planner_state <= PLANNER_PRIMING) {
+// st_prep_null();
+// return (STAT_NOOP);
+// }
+
// Run an out of band dwell. It was probably set in the previous st_load_move()
if (mr->out_of_band_dwell_flag) {
mr->out_of_band_dwell_flag = false;
@@ -258,7 +265,7 @@ stat_t mp_exec_move()
// first-time operations
if (bf->buffer_state != MP_BUFFER_RUNNING) {
if ((bf->buffer_state < MP_BUFFER_PREPPED) && (cm->motion_state == MOTION_RUN)) {
- debug_trap("mp_exec_move() buffer is not prepped. Starvation"); // IMPORTANT: can't rpt_exception from here!
+// debug_trap("mp_exec_move() buffer is not prepped. Starvation"); // IMPORTANT: can't rpt_exception from here!
st_prep_null();
return (STAT_NOOP);
}