Executing GCode through Moonraker/Mainsail

Hi developers,

I am trying to understand how Moonraker submits GCode to Klipper and how that GCode is being executed.

From what I know, Klipper does not have a GCode queue. It just uses a mutex to lock the GCode object and execute the entire “script”, which could be a single GCode command or an entire macro.

However, it seems that if the printer is running my PRINT_START macro and I submit a command through the Mainsail interface, that command does not wait for the end of the entire PRINT_START macro.

So, it seems that there is some interleaving of commands. I’d like to understand how that is done.

Thank you.

Moonraker uses the API Server: API server - Klipper documentation

Gcode macros are executed atomically - they will not be interleaved with other gcode commands. See render() in klippy/extras/gcode_macro.py and run_script_from_command() in klippy/gcode.py .

-Kevin