added error messages and dropped echoing of command input
This commit is contained in:
parent
9f5365aac9
commit
682e23eb7b
3
gcode.h
3
gcode.h
@ -27,8 +27,7 @@
|
|||||||
#define GCSTATUS_BAD_NUMBER_FORMAT 1
|
#define GCSTATUS_BAD_NUMBER_FORMAT 1
|
||||||
#define GCSTATUS_EXPECTED_COMMAND_LETTER 2
|
#define GCSTATUS_EXPECTED_COMMAND_LETTER 2
|
||||||
#define GCSTATUS_UNSUPPORTED_STATEMENT 3
|
#define GCSTATUS_UNSUPPORTED_STATEMENT 3
|
||||||
#define GCSTATUS_MOTION_CONTROL_ERROR 4
|
#define GCSTATUS_FLOATING_POINT_ERROR 4
|
||||||
#define GCSTATUS_FLOATING_POINT_ERROR 5
|
|
||||||
|
|
||||||
// Initialize the parser
|
// Initialize the parser
|
||||||
void gc_init();
|
void gc_init();
|
||||||
|
@ -31,6 +31,21 @@
|
|||||||
static char line[LINE_BUFFER_SIZE];
|
static char line[LINE_BUFFER_SIZE];
|
||||||
static uint8_t char_counter;
|
static uint8_t char_counter;
|
||||||
|
|
||||||
|
void status_message(int status_code) {
|
||||||
|
if (status_code) {
|
||||||
|
switch(status_code) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void prompt() {
|
void prompt() {
|
||||||
printPgmString(PSTR("ok\r\n"));
|
printPgmString(PSTR("ok\r\n"));
|
||||||
}
|
}
|
||||||
@ -50,10 +65,9 @@ void sp_process()
|
|||||||
while((c = serialRead()) != -1)
|
while((c = serialRead()) != -1)
|
||||||
{
|
{
|
||||||
if((char_counter > 0) && ((c == '\n') || (c == '\r'))) { // Line is complete. Then execute!
|
if((char_counter > 0) && ((c == '\n') || (c == '\r'))) { // Line is complete. Then execute!
|
||||||
line[char_counter] = 0;
|
line[char_counter] = 0; // treminate string
|
||||||
printString(line); printPgmString(PSTR("\r\n"));
|
status_message(gc_execute_line(line));
|
||||||
gc_execute_line(line);
|
char_counter = 0; // reset line buffer index
|
||||||
char_counter = 0;
|
|
||||||
prompt();
|
prompt();
|
||||||
} else if (c <= ' ') { // Throw away whitepace and control characters
|
} else if (c <= ' ') { // Throw away whitepace and control characters
|
||||||
} else if (c >= 'a' && c <= 'z') { // Upcase lowercase
|
} else if (c >= 'a' && c <= 'z') { // Upcase lowercase
|
||||||
|
Loading…
Reference in New Issue
Block a user