Do not reset line on serial commands without N

Fix regression introduced in fc10ca3146.

Accept incoming serial commands without line numbers (assumed to be
injected by the host), but do not reset the last line count when doing
so.
This commit is contained in:
Yuri D'Elia 2022-09-21 10:19:16 +02:00
parent 2bd4aef23e
commit 140961290d
2 changed files with 4 additions and 7 deletions

View File

@ -27,10 +27,7 @@ bool comment_mode = false;
char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc
ShortTimer serialTimeoutTimer; ShortTimer serialTimeoutTimer;
long gcode_N = 0;
long gcode_LastN = 0; long gcode_LastN = 0;
uint32_t sdpos_atomic = 0; uint32_t sdpos_atomic = 0;
@ -372,7 +369,7 @@ void get_command()
cmdbuffer[bufindw+serial_count+CMDHDRSIZE] = 0; //terminate string cmdbuffer[bufindw+serial_count+CMDHDRSIZE] = 0; //terminate string
if(!comment_mode){ if(!comment_mode){
gcode_N = 0; long gcode_N = -1;
// Line numbers must be first in buffer // Line numbers must be first in buffer
@ -459,7 +456,7 @@ void get_command()
// Command is complete: store the current line into buffer, move to the next line. // Command is complete: store the current line into buffer, move to the next line.
// Store type of entry // Store type of entry
cmdbuffer[bufindw] = gcode_N ? CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR : CMDBUFFER_CURRENT_TYPE_USB; cmdbuffer[bufindw] = gcode_N >= 0 ? CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR : CMDBUFFER_CURRENT_TYPE_USB;
#ifdef CMDBUFFER_DEBUG #ifdef CMDBUFFER_DEBUG
SERIAL_ECHO_START; SERIAL_ECHO_START;
@ -475,7 +472,8 @@ void get_command()
++ buflen; ++ buflen;
// Update the processed gcode line // Update the processed gcode line
gcode_LastN = gcode_N; if (gcode_N >= 0)
gcode_LastN = gcode_N;
#ifdef CMDBUFFER_DEBUG #ifdef CMDBUFFER_DEBUG
SERIAL_ECHOPGM("Number of commands in the buffer: "); SERIAL_ECHOPGM("Number of commands in the buffer: ");

View File

@ -52,7 +52,6 @@ extern int serial_count;
extern bool comment_mode; extern bool comment_mode;
extern char *strchr_pointer; extern char *strchr_pointer;
extern long gcode_N;
extern long gcode_LastN; extern long gcode_LastN;
extern bool cmdqueue_pop_front(); extern bool cmdqueue_pop_front();