# How to interrupt long command with G-code?

I was able to connect my terminal program (Putty) to my 3D Printer (Creality Ender 3 Pro) and was able to send G-code commands to my printer and it obeys.

Now suppose I sent long command like

G29 ; auto bed leveling


and it is still executing. Printer writes me

echo:busy: processing


How to interrupt it?

I tried to send M0, but it didn't work.

• Hi Dims! I did you resolve your question already? Would you like to accept one of existing answers, or maybe add your own input, looking from another angle? Or do you still have doubts which we could try to resolve together? – octopus8 Feb 5 at 2:59

3D Printers are pretty basic when it comes to g-code. There is no cycle start or cycle pause function on them. There is also no g-code command to interrupt the previous command. To get it to a halt you could turn it off. Or if the printer's firmware is configured to do so, you can touch one of the limit switches to get it to stop its movements.

G-Code is processed as a queue. The FIFO behavior would disallow to execute any commands in parallel.

However I am aware of - yet I didn't have opportunity to try - the emergency commands M112 or M108 offered by Marlin. Marlin documentation says that EMERGENCY_PARSER and HOST_KEEPALIVE_FEATURE need to be enabled to handle these. So apparently there is a mechanism which may work in parallel (like the higher priority queue?).

These commands may be designed to break execution of some specific actions, e.g. M108 was described to break wait-for-temperature loop. You may want to give it a try.

M0 also requires EMERGENCY_PARSER setting. And it may be bit different than you expect: it is described as pause after the last movement. By contrast, emergency codes (M112 full stop) are designed to jump the internal command queue even when printing and execute immediately, when emergency parser is enabled (command queue would be lost, printer may shut down or user may be forced to reboot the printer).

• Some commands are definetely can run in parallel. For example, I can start to heat extruder and meawhile move axes. – Dims Jan 6 at 19:07
• @Dims That's not really running in parallel. You're just issuing a "change temperature setpoint" command and once the setpoint has been updated, the command is considered finished. Thre are also G-code commands for changing various other settings (such as the steps per mm) but these are not "running" in any sense after they've been executed. – Tom van der Zanden Jan 6 at 19:16
• Commands like "Pause" get inserted after the completion of the last movement. However, there is the abort print command, that stops the execution of any G-code... but throws all commands out. – Trish Jan 7 at 9:45