Skip to content

Commit 51064f7

Browse files
committed
add get_current_line_number
1 parent bbdad79 commit 51064f7

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Marlin/src/gcode/gcode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
* R<temp> Wait for extruder current temp to reach target temp. ** Wait for heating or cooling. **
144144
* If AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
145145
*
146-
* M110 - Set the current line number. (Used by host printing)
146+
* M110 - Get or set the current line number. (Used by host printing)
147147
* M111 - Set debug flags: "M111 S<flagbits>". See flag bits defined in enum.h.
148148
* M112 - Full Shutdown.
149149
*

Marlin/src/gcode/host/M110.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
#include "../queue.h" // for last_N
2525

2626
/**
27-
* M110: Set Current Line Number
27+
* M110: Get or set Current Line Number
2828
*/
2929
void GcodeSuite::M110() {
3030

3131
if (parser.seenval('N'))
3232
queue.set_current_line_number(parser.value_long());
33-
33+
else
34+
SERIAL_ECHO_MSG("M110 N", queue.get_current_line_number());
3435
}

Marlin/src/gcode/queue.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ class GCodeQueue {
212212
*/
213213
static void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; }
214214

215+
/**
216+
* Get the current line number for the last received command
217+
*/
218+
static long get_current_line_number() { return serial_state[ring_buffer.command_port().index].last_N; }
219+
215220
#if ENABLED(BUFFER_MONITORING)
216221

217222
private:

0 commit comments

Comments
 (0)