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