MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
15.97k stars 19.09k forks source link

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

Closed ellensp closed 1 week ago

ellensp commented 2 weeks ago

Description

While looking around at how marlin handles gcode with line numbers and checksum I noticed there was no way to see the current line number.

M110 N#### sets the line number, but M110 on its own does nothing This PR changes M110 on its own to emit the current line number

eg send: M110 receive: echo: M110 N0

This adds a whole 6 bytes flash on Avr based machines, so I concluded that having a define to remove this new feature was probably not needed.

Requirements

None

Benefits

More constant gcode behavior (gcode without parameters tend to return the current settings for that gcode)

thinkyhead commented 1 week ago

The G-code line number is somewhat arbitrary, as it isn't the line in the G-code file, but just the line of commands that have been sent, potentially with comments and other stuff stripped out. I can see this being useful for debugging, but is there some host protocol that would need to get the line number of the last command that was received and enqueued just before the M110 command?

Note that the host is most likely to have already sent additional complete enqueued commands and command bytes that are yet to be enqueued at the time when the M110 (sent as a user command) processed in the queue. (Note that M110 is not a super-command like M112 and is processed in the regular queue order).

thinkyhead commented 1 week ago

Tweaked this to make it a real "protocol" feature, and added a note to remind us that this is related to M999.

thisiskeithb commented 1 week ago

Don't forget to update the M110 - Set Line Number page 😃