Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Premature termination of nested macro

    Scheduled Pinned Locked Moved
    Gcode meta commands
    4
    6
    375
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ardenpmundefined
      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:

      test_a.g

      if true
        echo "Yes"
      else
        echo "No"
      

      test_b.g

      if true
        M98 P"test_a.g"
        M98 P"test_a.g"
        M98 P"test_a.g"
      

      If I then run:

      M98 P"test_b.g"
      

      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 M98 calls are not inside an if clause then they do work as expected. So it appears to be something to do with the nesting of the if statements 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.

      gloomyandyundefined chrishammundefined 2 Replies Last reply Reply Quote 0
      • gloomyandyundefined
        gloomyandy @ardenpm
        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.

        ardenpmundefined 1 Reply Last reply Reply Quote 0
        • ardenpmundefined
          ardenpm @gloomyandy
          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.

          chrishammundefined 1 Reply Last reply Reply Quote 0
          • chrishammundefined
            chrishamm administrators @ardenpm
            last edited by

            @ardenpm Thanks, I can confirm this problem in standalone mode but not in SBC mode. I'll have a look.

            Duet software engineer

            1 Reply Last reply Reply Quote 1
            • chrishammundefined
              chrishamm administrators @ardenpm
              last edited by

              @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.

              Duet software engineer

              1 Reply Last reply Reply Quote 1
              • mikeabuilderundefined
                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).

                1 Reply Last reply Reply Quote 0
                • Exerqtorundefined Exerqtor referenced this topic
                • fcwiltundefined fcwilt referenced this topic
                • First post
                  Last post
                Unless otherwise noted, all forum content is licensed under CC-BY-SA