[LPC176x] Emergency Parser Feature (#10516)

This commit is contained in:
Chris Pepper
2018-04-25 12:44:26 +01:00
committed by Scott Lahteine
parent eef0248a1c
commit 2242b98248
15 changed files with 216 additions and 219 deletions

View File

@ -80,97 +80,8 @@
#endif
#if ENABLED(EMERGENCY_PARSER)
bool killed_by_M112; // = false
#include "../../module/stepper.h"
// Currently looking for: M108, M112, M410
// If you alter the parser please don't forget to update the capabilities in Conditionals_post.h
FORCE_INLINE void emergency_parser(const uint8_t c) {
static e_parser_state state = state_RESET;
switch (state) {
case state_RESET:
switch (c) {
case ' ': break;
case 'N': state = state_N; break;
case 'M': state = state_M; break;
default: state = state_IGNORE;
}
break;
case state_N:
switch (c) {
case '0': case '1': case '2':
case '3': case '4': case '5':
case '6': case '7': case '8':
case '9': case '-': case ' ': break;
case 'M': state = state_M; break;
default: state = state_IGNORE;
}
break;
case state_M:
switch (c) {
case ' ': break;
case '1': state = state_M1; break;
case '4': state = state_M4; break;
default: state = state_IGNORE;
}
break;
case state_M1:
switch (c) {
case '0': state = state_M10; break;
case '1': state = state_M11; break;
default: state = state_IGNORE;
}
break;
case state_M10:
state = (c == '8') ? state_M108 : state_IGNORE;
break;
case state_M11:
state = (c == '2') ? state_M112 : state_IGNORE;
break;
case state_M4:
state = (c == '1') ? state_M41 : state_IGNORE;
break;
case state_M41:
state = (c == '0') ? state_M410 : state_IGNORE;
break;
case state_IGNORE:
if (c == '\n') state = state_RESET;
break;
default:
if (c == '\n') {
switch (state) {
case state_M108:
wait_for_user = wait_for_heatup = false;
break;
case state_M112:
killed_by_M112 = true;
break;
case state_M410:
quickstop_stepper();
break;
default:
break;
}
state = state_RESET;
}
}
}
#endif // EMERGENCY_PARSER
#include "../../feature/emergency_parser.h"
#endif
FORCE_INLINE void store_rxd_char() {
@ -249,7 +160,7 @@
#endif // SERIAL_XON_XOFF
#if ENABLED(EMERGENCY_PARSER)
emergency_parser(c);
emergency_parser.update(c);
#endif
}

View File

@ -94,10 +94,6 @@
extern ring_buffer_pos_t rx_max_enqueued;
#endif
#if ENABLED(EMERGENCY_PARSER)
extern bool killed_by_M112;
#endif
class MarlinSerial { //: public Stream
public: