Don't fail on unknown commands. For example, RepRap host sends T commands,

which are not (yet) known.

Previously, the firmware would fail silently, which was even worse.
This commit is contained in:
Markus Hitter 2010-07-03 01:27:55 +02:00
parent a83f301a54
commit aa590c4502
1 changed files with 31 additions and 22 deletions

View File

@ -221,7 +221,7 @@ void scan_char(uint8_t c) {
// process character // process character
switch (c) { switch (c) {
// each command is either G or M, so preserve previous G/M unless a new one has appeared // each currently known command is either G or M, so preserve previous G/M unless a new one has appeared
case 'G': case 'G':
next_target.seen_G = 1; next_target.seen_G = 1;
next_target.seen_M = 0; next_target.seen_M = 0;
@ -294,8 +294,7 @@ void scan_char(uint8_t c) {
if ((c == 10) || (c == 13)) { if ((c == 10) || (c == 13)) {
if (debug_flags & DEBUG_ECHO) if (debug_flags & DEBUG_ECHO)
serial_writechar(c); serial_writechar(c);
// process
if (next_target.seen_G || next_target.seen_M) {
if ( if (
#ifdef REQUIRE_LINENUMBER #ifdef REQUIRE_LINENUMBER
((next_target.N >= next_target.N_expected) && (next_target.seen_N == 1)) ((next_target.N >= next_target.N_expected) && (next_target.seen_N == 1))
@ -310,9 +309,20 @@ void scan_char(uint8_t c) {
((next_target.checksum_calculated == next_target.checksum_read) || (next_target.seen_checksum == 0)) ((next_target.checksum_calculated == next_target.checksum_read) || (next_target.seen_checksum == 0))
#endif #endif
) { ) {
// process
if (next_target.seen_G || next_target.seen_M) {
process_gcode_command(&next_target); process_gcode_command(&next_target);
serial_writestr_P(PSTR("ok\n")); serial_writestr_P(PSTR("ok\n"));
}
else {
// write "OK" for invalid/unknown commands as well
#ifdef LOWERCASE_OK
serial_writestr_P(PSTR("ok huh?\n"));
#else
serial_writestr_P(PSTR("OK Huh?\n"));
#endif
}
// expect next line number // expect next line number
if (next_target.seen_N == 1) if (next_target.seen_N == 1)
@ -329,7 +339,6 @@ void scan_char(uint8_t c) {
serwrite_uint32(next_target.N_expected); serwrite_uint32(next_target.N_expected);
serial_writestr_P(PSTR("\n")); serial_writestr_P(PSTR("\n"));
} }
}
// reset variables // reset variables
next_target.seen_X = next_target.seen_Y = next_target.seen_Z = \ next_target.seen_X = next_target.seen_Y = next_target.seen_Z = \