kantlivelong / OctoPrint-GCodeSystemCommands

Define G-Code commands that execute local system commands.
GNU Affero General Public License v3.0
36 stars 20 forks source link

execution of GCODE macro, does not take into account waiting for commands to finish #24

Closed ruedli closed 1 year ago

ruedli commented 1 year ago

What were you doing?

I am using the GCODE macro script to run an end-sequence of the job, ensuring cooling down, shutdown Pi and poweroff. Shutdown and poweroff are done by the Tasmota plugin and work (using the M81 gcode)..

I have the following GCODE when finishing (a single line):

@shutdown_power

Shutdown power is defined as follows (also a single line):

{% include "shutdown_tasmota.gcode" %}

The content of the gcode file is:

pi@octopi:~/.octoprint/data/gcode_macro $ cat shutdown_tasmota.gcode

M117 Cooling down
;
M109 S50 ; wait for extruder temp (cooling)
M109 R50 ; wait for extruder temp (cooling)
G4 S1
;
M104 S0  ; turn off temperature

M117 Shutdown/poweroff

M81 MK3S 1
;======================= Stop printer

Strictly speaking only one M109 R50 is needed, but I used both just to be sure the firmware is not causing a problem.

The problem is that "M81 MK3S 1" is executed, without waiting for the printer to cooldown. It looks like it is "just" executing", but not waiting for the command to complete.

By contrast: if I add the M109 to the endcode, everything works, so whithout the scipt altered, these three lines work as a workaround:

M109 S50 ;
M109 R50 ;
@shutdown_power

ALSO: If I split the commands over two macros, it works:

@cooldown
@shutdown_power

Using a prusa MK3S+, latest firmware 3.12.2 System bundle included. octoprint-systeminfo-20230613195238.zip

kantlivelong commented 1 year ago

I'm confused as to where the OCTO## GCode command comes into play here?

ruedli commented 1 year ago

You are absolutely right! I went through the plugin manager, but followed the wrong link: should have been for "GCODE macros"