Merge pull request #235 from thess/M110-fix

Fix parsing of M110 command
This commit is contained in:
PavelSindler 2017-10-20 16:25:14 +02:00 committed by GitHub
commit 0438a8effd
1 changed files with 18 additions and 14 deletions

View File

@ -1497,14 +1497,16 @@ void get_command()
} }
cmdbuffer[bufindw+serial_count+1] = 0; //terminate string cmdbuffer[bufindw+serial_count+1] = 0; //terminate string
if(!comment_mode){ if(!comment_mode){
if ((strchr_pointer = strstr(cmdbuffer+bufindw+1, "PRUSA")) == NULL && (strchr_pointer = strchr(cmdbuffer+bufindw+1, 'N')) != NULL) { // Line numbers must be first in buffer
if ((strchr_pointer = strchr(cmdbuffer+bufindw+1, 'N')) != NULL) if ((strstr(cmdbuffer+bufindw+1, "PRUSA") == NULL) &&
{ (cmdbuffer[bufindw + 1] == 'N')) {
// Line number met. When sending a G-code over a serial line, each line may be stamped with its index, // Line number met. When sending a G-code over a serial line, each line may be stamped with its index,
// and Marlin tests, whether the successive lines are stamped with an increasing line number ID. // and Marlin tests, whether the successive lines are stamped with an increasing line number ID.
gcode_N = (strtol(strchr_pointer+1, NULL, 10)); gcode_N = (strtol(cmdbuffer + bufindw + 2, NULL, 10));
if(gcode_N != gcode_LastN+1 && (strstr_P(cmdbuffer+bufindw+1, PSTR("M110")) == NULL) ) { if ((gcode_N != gcode_LastN + 1) &&
// M110 - set current line number. (strstr_P(cmdbuffer+bufindw+1, PSTR("M110")) == NULL))
{
// Line numbers not sent in succession. // Line numbers not sent in succession.
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORRPGM(MSG_ERR_LINE_NO); SERIAL_ERRORRPGM(MSG_ERR_LINE_NO);
@ -1542,21 +1544,23 @@ void get_command()
return; return;
} }
gcode_LastN = gcode_N; // Don't parse N again with code_seen('N')
cmdbuffer[bufindw + 1] = '$';
//if no errors, continue parsing //if no errors, continue parsing
} // end of 'N' command gcode_LastN = gcode_N;
} }
else // if we don't receive 'N' but still see '*'
// if we don't receive 'N' but still see '*'
if((cmdbuffer[bufindw + 1] != 'N') && (cmdbuffer[bufindw + 1] != '$') &&
(strchr(cmdbuffer + bufindw + 1, '*') != NULL))
{ {
if((strchr(cmdbuffer+bufindw+1, '*') != NULL))
{
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORRPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM); SERIAL_ERRORRPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM);
SERIAL_ERRORLN(gcode_LastN); SERIAL_ERRORLN(gcode_LastN);
serial_count = 0; serial_count = 0;
return; return;
} }
} // end of '*' command
if ((strchr_pointer = strchr(cmdbuffer+bufindw+1, 'G')) != NULL) { if ((strchr_pointer = strchr(cmdbuffer+bufindw+1, 'G')) != NULL) {
if (! IS_SD_PRINTING) { if (! IS_SD_PRINTING) {
usb_printing_counter = 10; usb_printing_counter = 10;