diff --git a/script/stream.rb b/script/stream.rb index 608add2..d3f6d76 100644 --- a/script/stream.rb +++ b/script/stream.rb @@ -38,8 +38,8 @@ SerialPort.open('/dev/tty.usbserial-A700e0GO', 9600) do |sp| if prebuffer == 0 begin result = sp.gets.strip - puts "Grbl >> #{result}" unless result == '' or result == 'ok' - end while result != 'ok' + puts "Grbl >> #{result}" #unless result == 'ok' + end while !(result =~ /^ok|^error/) else prebuffer -= 1 end diff --git a/serial_protocol.c b/serial_protocol.c index 78b7493..f2dcd47 100644 --- a/serial_protocol.c +++ b/serial_protocol.c @@ -33,23 +33,21 @@ static char line[LINE_BUFFER_SIZE]; static uint8_t char_counter; void status_message(int status_code) { - if (status_code) { - switch(status_code) { - case GCSTATUS_OK: - printPgmString(PSTR("ok\r\n")); break; - case GCSTATUS_BAD_NUMBER_FORMAT: - printPgmString(PSTR("error: Bad number format\n\r")); break; - case GCSTATUS_EXPECTED_COMMAND_LETTER: - printPgmString(PSTR("error: Expected command letter\n\r")); break; - case GCSTATUS_UNSUPPORTED_STATEMENT: - printPgmString(PSTR("error: Unsupported statement\n\r")); break; - case GCSTATUS_FLOATING_POINT_ERROR: - printPgmString(PSTR("error: Floating point error\n\r")); break; - default: - printPgmString(PSTR("error: ")); - printInteger(status_code); - printPgmString(PSTR("\n\r")); - } + switch(status_code) { + case GCSTATUS_OK: + printPgmString(PSTR("ok\n\r")); break; + case GCSTATUS_BAD_NUMBER_FORMAT: + printPgmString(PSTR("error: Bad number format\n\r")); break; + case GCSTATUS_EXPECTED_COMMAND_LETTER: + printPgmString(PSTR("error: Expected command letter\n\r")); break; + case GCSTATUS_UNSUPPORTED_STATEMENT: + printPgmString(PSTR("error: Unsupported statement\n\r")); break; + case GCSTATUS_FLOATING_POINT_ERROR: + printPgmString(PSTR("error: Floating point error\n\r")); break; + default: + printPgmString(PSTR("error: ")); + printInteger(status_code); + printPgmString(PSTR("\n\r")); } }