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

    Macro gets stuck in a while loop after update to RRF 3.4 rc1

    Scheduled Pinned Locked Moved Solved
    Gcode meta commands
    4
    5
    162
    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.
    • MaxGyverundefined
      MaxGyver
      last edited by

      After updating to RRF 3.4 rc1 my macros that are using while statements are getting stuck in a loop. Executing the macro results is a never-ending loop, blocking all other inputs, often freezing the web interface. Somewhere I read that the behavior of G4 has changed with the new release. But I was unable to find that information.

      while true
       if heat.heaters[2].current > heat.heaters[2].active
        M118 S"Fan ON"
        M106 P0 S1 X0.5; turn on cooling fan 
        G4 S1 ; wait a sec
       else	
        M106 P0 S0 ;turn fan off
        M118 S"Fan OFF"
      endwhile
      

      -Max

      Stephen6309undefined OwenDundefined 2 Replies Last reply Reply Quote 0
      • MaxGyverundefined MaxGyver marked this topic as a question
      • OwenDundefined
        OwenD @MaxGyver
        last edited by

        @maxgyver
        Your code kind of makes sense if it's an enclosure fan and it's being monitored in daemon.g , but as a stand alone macro, it is doing exactly as you asked, which as others have pointed out stay in a loop.
        It will also be very annoying getting all this M118 messages.

        You should add consider adding an AND "&&" statement to only run each section if the fan is already on or off respectively.

        also

        endwhile is not valid
        You need to comment it out if you're using it as a placeholder

        MaxGyverundefined 1 Reply Last reply Reply Quote 0
        • infiniteloopundefined
          infiniteloop
          last edited by

          @MaxGyver And when did you intend to leave the macro? As I read it, there is no exit ever …

          1 Reply Last reply Reply Quote 0
          • Stephen6309undefined
            Stephen6309 @MaxGyver
            last edited by

            @maxgyver You need to add M99 after the G4 and M118 to exit the macro, otherwise it runs forever.

            1 Reply Last reply Reply Quote 0
            • OwenDundefined
              OwenD @MaxGyver
              last edited by

              @maxgyver
              Your code kind of makes sense if it's an enclosure fan and it's being monitored in daemon.g , but as a stand alone macro, it is doing exactly as you asked, which as others have pointed out stay in a loop.
              It will also be very annoying getting all this M118 messages.

              You should add consider adding an AND "&&" statement to only run each section if the fan is already on or off respectively.

              also

              endwhile is not valid
              You need to comment it out if you're using it as a placeholder

              MaxGyverundefined 1 Reply Last reply Reply Quote 0
              • MaxGyverundefined
                MaxGyver @OwenD
                last edited by

                @owend said in Macro gets stuck in a while loop after update to RRF 3.4 rc1:

                Your code kind of makes sense if it's an enclosure fan and it's being monitored in daemon.g , but as a stand alone macro, it is doing exactly as you asked, which as others have pointed out stay in a loop.

                Yep, that is precisely what it is intended for. In daemon.g the code works now, since I exclusively used the loop in daemon.g I was not aware of the effect it has on “normal” macros.

                Thank you!

                1 Reply Last reply Reply Quote 0
                • MaxGyverundefined MaxGyver has marked this topic as solved
                • First post
                  Last post
                Unless otherwise noted, all forum content is licensed under CC-BY-SA