Simplify emergency parser (only parse initial command)

master
Scott Lahteine 9 years ago
parent 834ad14c8d
commit ea47803ae2

@ -325,12 +325,11 @@ MarlinSerial customizedSerial;
enum e_parser_state { enum e_parser_state {
state_RESET, state_RESET,
state_N,
state_M, state_M,
state_M1, state_M1,
state_M10, state_M10,
state_M11, state_M11,
state_M2,
state_M3,
state_M4, state_M4,
state_M41, state_M41,
state_IGNORE // to '\n' state_IGNORE // to '\n'
@ -338,131 +337,68 @@ MarlinSerial customizedSerial;
static e_parser_state state = state_RESET; static e_parser_state state = state_RESET;
if (c == '\n') state = state_IGNORE;
switch (state) { switch (state) {
case state_RESET: case state_RESET:
switch (c) { switch (c) {
case 'M': case ' ': break;
state = state_M; case 'N': state = state_N; break;
break; case 'M': state = state_M; break;
case ';': default: state = state_IGNORE;
state = state_IGNORE;
break;
default: state = state_RESET;
}
break;
case state_M:
switch (c) {
case '1':
state = state_M1;
break;
case '2':
state = state_M2;
break;
case '3':
state = state_M3;
break;
case '4':
state = state_M4;
break;
case ';':
state = state_IGNORE;
break;
default: state = state_RESET;
} }
break; break;
case state_M1: case state_N:
switch (c) { switch (c) {
case '0': case '0': case '1': case '2':
state = state_M10; case '3': case '4': case '5':
break; case '6': case '7': case '8':
case '1': case '9': case '-': case ' ': break;
state = state_M11; case 'M': state = state_M; break;
break; default: state = state_IGNORE;
case ';':
state = state_IGNORE;
break;
default: state = state_RESET;
} }
break; break;
case state_M2: case state_M:
switch (c) { switch (c) {
case '3': // M23 case ' ': break;
case '8': // M28 case '1': state = state_M1; break;
case ';': case '4': state = state_M4; break;
state = state_IGNORE; default: state = state_IGNORE;
break;
default: state = state_RESET;
} }
break; break;
case state_M3: case state_M1:
switch (c) { switch (c) {
case '0': // M30 case '0': state = state_M10; break;
case '2': // M32 case '1': state = state_M11; break;
case '3': // M33 default: state = state_IGNORE;
case ';':
state = state_IGNORE;
break;
default: state = state_RESET;
} }
break; break;
case state_M10: case state_M10:
switch (c) { if (c == '8') wait_for_heatup = false; // M108
case '8': // M108 state = state_IGNORE;
{ state = state_RESET; wait_for_heatup = false; } break;
break;
case ';':
state = state_IGNORE;
break;
default: state = state_RESET;
}
break;
case state_M11: case state_M11:
switch (c) { if (c == '2') kill(PSTR(MSG_KILLED)); // M112
case '2': // M112 state = state_IGNORE;
state = state_RESET; kill(PSTR(MSG_KILLED)); break;
break;
case '7': // M117
case ';':
state = state_IGNORE;
break;
default: state = state_RESET;
}
break;
case state_M4: case state_M4:
switch (c) { state = (c == '1') ? state_M41 : state_IGNORE;
case '1': break;
state = state_M41;
break;
case ';':
state = state_IGNORE;
break;
default: state = state_RESET;
}
break;
case state_M41: case state_M41:
switch (c) { if (c == '0') quickstop_stepper(); // M410
case '0': state = state_IGNORE;
state = state_RESET; break;
quickstop_stepper();
break;
case ';':
state = state_IGNORE;
break;
default: state = state_RESET;
}
break;
case state_IGNORE: case state_IGNORE:
if (c == '\n') state = state_RESET; if (c == '\n') state = state_RESET;
break; break;
default: default:
state = state_RESET; state = state_RESET;

Loading…
Cancel
Save