Skip to content

add get_current_line_number as default action for gcode M110 without N parameter #27090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
#define STR_BUSY_PAUSED_FOR_USER "busy: paused for user"
#define STR_BUSY_PAUSED_FOR_INPUT "busy: paused for input"
#define STR_Z_MOVE_COMP "Z_move_comp"
#define STR_LINE_NO "Line: "
#define STR_RESEND "Resend: "
#define STR_UNKNOWN_COMMAND "Unknown command: \""
#define STR_ACTIVE_EXTRUDER "Active Extruder: "
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
* R<temp> Wait for extruder current temp to reach target temp. ** Wait for heating or cooling. **
* If AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
*
* M110 - Set the current line number. (Used by host printing)
* M110 - Get or set the current line number. (Used by host printing)
* M111 - Set debug flags: "M111 S<flagbits>". See flag bits defined in enum.h.
* M112 - Full Shutdown.
*
Expand Down
12 changes: 10 additions & 2 deletions Marlin/src/gcode/host/M110.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@
#include "../queue.h" // for last_N

/**
* M110: Set Current Line Number
* M110: Get or set Current Line Number
*
* Parameters:
* N<int> Number to set as last-processed command
*
* Without parameters:
* Report the last-processed (not last-received or last-enqueued) command
* (To purge the queue and resume from this line, the host should use 'M999' instead.)
*/
void GcodeSuite::M110() {

if (parser.seenval('N'))
queue.set_current_line_number(parser.value_long());

else
SERIAL_ECHOLNPGM(STR_LINE_NO, queue.get_current_line_number());
}
5 changes: 5 additions & 0 deletions Marlin/src/gcode/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ class GCodeQueue {
*/
static void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; }

/**
* Get the current line number for the last received command
*/
static long get_current_line_number() { return serial_state[ring_buffer.command_port().index].last_N; }

#if ENABLED(BUFFER_MONITORING)

private:
Expand Down