Cancelling a print during a while loop breaks local variables
-
Hello,
I have been experiencing this issue for awhile but have been able to narrow down my issue recently. My issue occurs when cancelling a print, or a print cancelling itself (such as forgetting an R parameter on an arc move) during a while loop. Once that happens, I can no longer print that file again even if I edit it. It gives me the reply that the variable is no longer existent. I replicated the issue using this code:M207 P2 Z2 F4000 S30 R10 T2000 var parts = 4 while iterations < var.parts G1 X9.0402 Y0.0 G1 Z2.0 F2000 ;G11 G3 X6.39236 Y6.39236 Z2.5 F600 r9.0402 G3 X0.0 Y9.0402 Z2.5 r9.0402 G3 X-6.39236 Y6.39236 Z2.5 r9.0402 G3 X-9.0402 Y0.0 Z2.5 r9.0402 G3 X-6.39236 Y-6.39236 Z2.5 r9.0402 G3 X0.0 Y-9.0402 Z2.5 r9.0402 G3 X6.39236 Y-6.39236 Z2.5 r9.0402 G3 X9.0402 Y0.0 Z3.0 r9.0402 G3 X6.39236 Y6.39236 Z3.0 r9.0402 G3 X0.0 Y9.0402 Z3.0 r9.0402 G3 X-6.39236 Y6.39236 Z3.0 r9.0402 G3 X-9.0402 Y0.0 Z3.0 r9.0402 ;G10 G4 S1 M98 P"0:/macros/Project Macros/PS/Next Part" M0
I run the above code and cancel the print during the while loop. I then tried to run the file again after editing a line and received the error message that "parts" is already declared or non existent. This is my console log when I replicated the issue:
4/26/2023, 7:44:41 AM M32 "0:/gcodes/C3DM/loop-failure.gcode" File 0:/gcodes/C3DM/loop-failure.gcode selected for printing Error: in GCode file line 6 column 29: meta command: unknown variable 'parts' Cancelled printing file 0:/gcodes/C3DM/loop-failure.gcode, print time was 0h 0m 4/26/2023, 7:44:27 AM Upload of loop-failure.gcode successful after 4s 4/26/2023, 7:43:54 AM M0 Cancelled printing file 0:/gcodes/C3DM/loop-failure.gcode, print time was 0h 0m 4/26/2023, 7:43:45 AM M25 Resume state saved Printing paused at X300.2 Y105.3 Z55.0 4/26/2023, 7:43:20 AM M32 "0:/gcodes/C3DM/loop-failure.gcode" File 0:/gcodes/C3DM/loop-failure.gcode selected for printing
I am able to print the file again if I upload the file again as a different name. It also allows me to print the file again if I rename the file. The only other way I have been able to reprint the files is to send M999 to reset the board.
When there are multiple variables, the issue also affects those as well. It only affects local variables. This issue does not happen if I let the loop finish executing before cancelling the print. I have experienced this issue on every Duet board I have used. I believe that this is a bug.
Let me know if I can provide more information. Thanks
-
@bcrass what firmware version are you running? standalone or SBC?
-
@jay_s_uk DWC version 3.4.5 as well as RRF 3.4.5, in standalone mode.
-
@jay_s_uk I have just tested another board that is on RRF / DWC 3.3 that is on SBC mode and the issue is the same
-
@bcrass What do you have in
0:/macros/Project Macros/PS/Next Part
? -
@chrishamm this happens even when stopping prior to the macro but this is what the macro looks like.
var maxX = 361 var maxY = 141 var minX = 224.4 var minY = 37.5 var spacing = 35.5 var nextRow = 76 G1 F7000 G55 G1 X0 Y0 Z5 G10 P2 L20 X{-var.spacing} Y0 Z5 if {move.axes[0].workplaceOffsets[1]} > var.maxX echo "next row" G1 X0 Y0 G10 P2 L2 X{var.minX} G10 P2 L20 Y{-var.nextRow} if {move.axes[1].workplaceOffsets[1]} > var.maxY echo "back to initial position" G10 P2 L2 X{var.minX} Y{var.minY}
-
I was able to create another issue with simpler g-code. When cancelling the print during the while loop, selecting the file for printing again will resume from the cancel location instead of starting from the beginning. I let the print finish executing the rest of the loop and then attempted to print again, but was met with the error: variable 'parts' already exists. It is impossible to start the print from this point without an E-stop or an M999 command.
echo "Begin" var parts = 0 while var.parts < 5 G1 X0 Y0 Z20 F3000 G1 X30 G1 Y30 G1 X0 G1 Y0 G10 P2 L20 X-50 Y0 Z20 set var.parts = var.parts + 1 echo "end" M0
-