Premature termination of nested macro
ardenpm last edited by
I'm having an issue with some Gcode scripts I have setup which are calling each other but stopping execution for no apparent reason with no errors. I believe it can be reproduced with the following:
if true echo "Yes" else echo "No"
if true M98 P"test_a.g" M98 P"test_a.g" M98 P"test_a.g"
If I then run:
I get only a single "Yes" printed to the console. If I edit test_a.g to be:
if true echo "Yes" else echo "No" echo "Done"
I get then then expected three "Yes" strings output (and of course three "Done" strings as well). The above example is a cut down minimal reproduction case from a much more complex script.
Note that in test_b.g, if the
M98calls are not inside an
ifclause then they do work as expected. So it appears to be something to do with the nesting of the
ifstatements across nested macro calls.
The absence or presents of a final newline has no effect on the issue. Note also the failure is silent, there are no errors it just stops executing code.
I'm on RRF3.4.1, not sure if this is definitely a bug and whether I should file it on Github or not so hoping for a sanity check here.
gloomyandy last edited by
@ardenpm Are you running this test using the DWC console? If so you might want to try running it using a USB terminal connection. I'm sure in the past I've seen examples of lost console output when using DWC, especially when the output is identical strings.
ardenpm last edited by
@gloomyandy It is in DWC, however the console output approach above is just to simplify it for the reproduction case so it could be run without having to move or print. In the real case where I encountered the issue there were moves and extrusion so it was pretty obvious it had stopped since nothing was moving or extruding.
@ardenpm Thanks, I can confirm this problem in standalone mode but not in SBC mode. I'll have a look.
@ardenpm I haven't come up with a fix yet but you can work-around this problem by putting a command like
echo ""at the end of test_a.g without indentation.
mikeabuilder last edited by
I would also guess maybe putting a G4 P0 after the M98 lines in the test.b file might be instructive. I can imagine the console messages not buffering (are they supposed to buffer?). I might also make testa.g have a parameter that you then echo along with the answer, and have test .g supply a unique value on each m98 call. This would let you see which of teh M98 calls are getting lost (the presumption is it's lat last getting lost, but nice to know for sure).