From ce369642798f5aee3341ffa9d00191d538014d71 Mon Sep 17 00:00:00 2001 From: Ted Hess Date: Mon, 1 Jan 2018 15:55:06 -0500 Subject: [PATCH] Set command type before parsing line. Skip leading whitespace. --- Firmware/Marlin_main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index cdef1fe01..5431a550f 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1499,6 +1499,12 @@ void get_command() return; } 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){ // Line numbers must be first in buffer if ((strstr(cmdbuffer+bufindw+1, "PRUSA") == NULL) && @@ -1581,9 +1587,8 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer+bufindw+1, "M112") == 0) kill(); - + // Store the current line into buffer, move to the next line. - cmdbuffer[bufindw] = CMDBUFFER_CURRENT_TYPE_USB; #ifdef CMDBUFFER_DEBUG SERIAL_ECHO_START; SERIAL_ECHOPGM("Storing a command line to buffer: ");