Set command type before parsing line. Skip leading whitespace.

This commit is contained in:
Ted Hess 2018-01-01 15:55:06 -05:00
parent b381e51a13
commit ce36964279
1 changed files with 7 additions and 2 deletions

View File

@ -1499,6 +1499,12 @@ void get_command()
return; return;
} }
cmdbuffer[bufindw+serial_count+1] = 0; //terminate string cmdbuffer[bufindw+serial_count+1] = 0; //terminate string
// Skip leading whitespace
while(cmdbuffer[bufindw + 1] == ' ') bufindw++;
// Set command type here so correct responses are sent in case line error
cmdbuffer[bufindw] = CMDBUFFER_CURRENT_TYPE_USB;
if(!comment_mode){ if(!comment_mode){
// Line numbers must be first in buffer // Line numbers must be first in buffer
if ((strstr(cmdbuffer+bufindw+1, "PRUSA") == NULL) && if ((strstr(cmdbuffer+bufindw+1, "PRUSA") == NULL) &&
@ -1581,9 +1587,8 @@ void get_command()
//If command was e-stop process now //If command was e-stop process now
if(strcmp(cmdbuffer+bufindw+1, "M112") == 0) if(strcmp(cmdbuffer+bufindw+1, "M112") == 0)
kill(); kill();
// Store the current line into buffer, move to the next line. // Store the current line into buffer, move to the next line.
cmdbuffer[bufindw] = CMDBUFFER_CURRENT_TYPE_USB;
#ifdef CMDBUFFER_DEBUG #ifdef CMDBUFFER_DEBUG
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPGM("Storing a command line to buffer: "); SERIAL_ECHOPGM("Storing a command line to buffer: ");