|
|
@ -34,29 +34,33 @@ |
|
|
|
// External references
|
|
|
|
extern bool wait_for_user, wait_for_heatup; |
|
|
|
|
|
|
|
#if ENABLED(REALTIME_REPORTING_COMMANDS) |
|
|
|
// From motion.h, which cannot be included here
|
|
|
|
void report_current_position_moving(); |
|
|
|
void quickpause_stepper(); |
|
|
|
void quickresume_stepper(); |
|
|
|
#endif |
|
|
|
|
|
|
|
class EmergencyParser { |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
// Currently looking for: M108, M112, M410, M876
|
|
|
|
enum State : char { |
|
|
|
// Currently looking for: M108, M112, M410, M876 S[0-9], S000, P000, R000
|
|
|
|
enum State : uint8_t { |
|
|
|
EP_RESET, |
|
|
|
EP_N, |
|
|
|
EP_M, |
|
|
|
EP_M1, |
|
|
|
EP_M10, |
|
|
|
EP_M108, |
|
|
|
EP_M11, |
|
|
|
EP_M112, |
|
|
|
EP_M4, |
|
|
|
EP_M41, |
|
|
|
EP_M410, |
|
|
|
EP_M10, EP_M108, |
|
|
|
EP_M11, EP_M112, |
|
|
|
EP_M4, EP_M41, EP_M410, |
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT) |
|
|
|
EP_M8, |
|
|
|
EP_M87, |
|
|
|
EP_M876, |
|
|
|
EP_M876S, |
|
|
|
EP_M876SN, |
|
|
|
EP_M8, EP_M87, EP_M876, EP_M876S, EP_M876SN, |
|
|
|
#endif |
|
|
|
#if ENABLED(REALTIME_REPORTING_COMMANDS) |
|
|
|
EP_S, EP_S0, EP_S00, EP_GRBL_STATUS, |
|
|
|
EP_R, EP_R0, EP_R00, EP_GRBL_RESUME, |
|
|
|
EP_P, EP_P0, EP_P00, EP_GRBL_PAUSE, |
|
|
|
#endif |
|
|
|
EP_IGNORE // to '\n'
|
|
|
|
}; |
|
|
@ -71,7 +75,6 @@ public: |
|
|
|
EmergencyParser() { enable(); } |
|
|
|
|
|
|
|
FORCE_INLINE static void enable() { enabled = true; } |
|
|
|
|
|
|
|
FORCE_INLINE static void disable() { enabled = false; } |
|
|
|
|
|
|
|
FORCE_INLINE static void update(State &state, const uint8_t c) { |
|
|
@ -81,6 +84,11 @@ public: |
|
|
|
case ' ': case '\n': case '\r': break; |
|
|
|
case 'N': state = EP_N; break; |
|
|
|
case 'M': state = EP_M; break; |
|
|
|
#if ENABLED(REALTIME_REPORTING_COMMANDS) |
|
|
|
case 'S': state = EP_S; break; |
|
|
|
case 'P': state = EP_P; break; |
|
|
|
case 'R': state = EP_R; break; |
|
|
|
#endif |
|
|
|
default: state = EP_IGNORE; |
|
|
|
} |
|
|
|
break; |
|
|
@ -90,10 +98,29 @@ public: |
|
|
|
case '0' ... '9': |
|
|
|
case '-': case ' ': break; |
|
|
|
case 'M': state = EP_M; break; |
|
|
|
#if ENABLED(REALTIME_REPORTING_COMMANDS) |
|
|
|
case 'S': state = EP_S; break; |
|
|
|
case 'P': state = EP_P; break; |
|
|
|
case 'R': state = EP_R; break; |
|
|
|
#endif |
|
|
|
default: state = EP_IGNORE; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
#if ENABLED(REALTIME_REPORTING_COMMANDS) |
|
|
|
case EP_S: state = (c == '0') ? EP_S0 : EP_IGNORE; break; |
|
|
|
case EP_S0: state = (c == '0') ? EP_S00 : EP_IGNORE; break; |
|
|
|
case EP_S00: state = (c == '0') ? EP_GRBL_STATUS : EP_IGNORE; break; |
|
|
|
|
|
|
|
case EP_R: state = (c == '0') ? EP_R0 : EP_IGNORE; break; |
|
|
|
case EP_R0: state = (c == '0') ? EP_R00 : EP_IGNORE; break; |
|
|
|
case EP_R00: state = (c == '0') ? EP_GRBL_RESUME : EP_IGNORE; break; |
|
|
|
|
|
|
|
case EP_P: state = (c == '0') ? EP_P0 : EP_IGNORE; break; |
|
|
|
case EP_P0: state = (c == '0') ? EP_P00 : EP_IGNORE; break; |
|
|
|
case EP_P00: state = (c == '0') ? EP_GRBL_PAUSE : EP_IGNORE; break; |
|
|
|
#endif |
|
|
|
|
|
|
|
case EP_M: |
|
|
|
switch (c) { |
|
|
|
case ' ': break; |
|
|
@ -114,30 +141,15 @@ public: |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
case EP_M10: |
|
|
|
state = (c == '8') ? EP_M108 : EP_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case EP_M11: |
|
|
|
state = (c == '2') ? EP_M112 : EP_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case EP_M4: |
|
|
|
state = (c == '1') ? EP_M41 : EP_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case EP_M41: |
|
|
|
state = (c == '0') ? EP_M410 : EP_IGNORE; |
|
|
|
break; |
|
|
|
case EP_M10: state = (c == '8') ? EP_M108 : EP_IGNORE; break; |
|
|
|
case EP_M11: state = (c == '2') ? EP_M112 : EP_IGNORE; break; |
|
|
|
case EP_M4: state = (c == '1') ? EP_M41 : EP_IGNORE; break; |
|
|
|
case EP_M41: state = (c == '0') ? EP_M410 : EP_IGNORE; break; |
|
|
|
|
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT) |
|
|
|
case EP_M8: |
|
|
|
state = (c == '7') ? EP_M87 : EP_IGNORE; |
|
|
|
break; |
|
|
|
|
|
|
|
case EP_M87: |
|
|
|
state = (c == '6') ? EP_M876 : EP_IGNORE; |
|
|
|
break; |
|
|
|
case EP_M8: state = (c == '7') ? EP_M87 : EP_IGNORE; break; |
|
|
|
case EP_M87: state = (c == '6') ? EP_M876 : EP_IGNORE; break; |
|
|
|
|
|
|
|
case EP_M876: |
|
|
|
switch (c) { |
|
|
@ -152,10 +164,11 @@ public: |
|
|
|
case ' ': break; |
|
|
|
case '0' ... '9': |
|
|
|
state = EP_M876SN; |
|
|
|
M876_reason = (uint8_t)(c - '0'); |
|
|
|
M876_reason = uint8_t(c - '0'); |
|
|
|
break; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
case EP_IGNORE: |
|
|
@ -171,6 +184,11 @@ public: |
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT) |
|
|
|
case EP_M876SN: host_response_handler(M876_reason); break; |
|
|
|
#endif |
|
|
|
#if ENABLED(REALTIME_REPORTING_COMMANDS) |
|
|
|
case EP_GRBL_STATUS: report_current_position_moving(); break; |
|
|
|
case EP_GRBL_PAUSE: quickpause_stepper(); break; |
|
|
|
case EP_GRBL_RESUME: quickresume_stepper(); break; |
|
|
|
#endif |
|
|
|
default: break; |
|
|
|
} |
|
|
|
state = EP_RESET; |
|
|
|