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

    Can't edit/save daemon.g that contains a 1 sec loop.

    Scheduled Pinned Locked Moved
    General Discussion
    9
    24
    768
    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.
    • zaptaundefined
      zapta @chrishamm
      last edited by

      @chrishamm, having a loop just for a single 10sec slot is a good idea. I will give it a try. My concern is the timing on boundary of daemon.g invocations. Having the reset the board is also reasonable since it's a big red accessible button on the screen.

      Let's say that daemon.g is invoked at time T=0 and takes 10.5 secs to complete. When will the next invocation of daemon.g occur, at T=10.5 or at T=20?

      1 Reply Last reply Reply Quote 0
      • Tinchusundefined
        Tinchus
        last edited by

        sorry to interrupt: my daemon.g now it is like this:

        if global.runDaemon = true
        while true
        mycode
        G4 S2

        This should allow me to stop it if I set the variable to false, and if it is true, the daemon.g executes every 2 seconds, is this ok?

        zaptaundefined 1 Reply Last reply Reply Quote 0
        • zaptaundefined
          zapta @Tinchus
          last edited by

          @Tinchus, I believe that you need to have a conditional exit with the loop such that the code keeps evaluating the condition.

          Tinchusundefined 1 Reply Last reply Reply Quote 0
          • Tinchusundefined
            Tinchus @zapta
            last edited by Tinchus

            @zapta sorry, I paste but indentation was deleted, the daemong looks like this:

            if global.runDaemon = true
                  while true
                       mycode
                       G4 S2
            

            And of course inside the "mycode" section, Have some G4 S0.5 to be sure the while is not running forever.

            This is workign ok for me now, but I have just noticed that if I delete the if global.runDaemon = true I still can edit and save the daeom.g file... may be with latest versions of firmware now the file is not locked for edition anymore while still being active?

            PD: indentation was erased again... ok, beleiveme , my daemon is running ok every 2 seconds jajajaja

            zaptaundefined dc42undefined 2 Replies Last reply Reply Quote 0
            • zaptaundefined
              zapta @Tinchus
              last edited by

              @Tinchus, to post code here you can use the </> button. It will preserve the indentation.

              example:

              code1
                code2
                  code3
              
              zaptaundefined 1 Reply Last reply Reply Quote 0
              • zaptaundefined
                zapta @zapta
                last edited by zapta

                Once you check the flag once and enter the infinite loop, the flag is not examined anymore so the loop will not stop when runDaemon becomes false.

                How do you sent the flag to false to stop the daemon and do you restart the machine to do so?

                Tinchusundefined 1 Reply Last reply Reply Quote 0
                • Tinchusundefined
                  Tinchus @zapta
                  last edited by

                  @zapta yes, I restarted the machine several times, for some reason I can edit and save the daemon.g without renaming it at all. I just edit it on the iterface, save it and it is being accepted...

                  fcwiltundefined 1 Reply Last reply Reply Quote 0
                  • fcwiltundefined
                    fcwilt @Tinchus
                    last edited by

                    @Tinchus said in Can't edit/save daemon.g that contains a 1 sec loop.:

                    @zapta yes, I restarted the machine several times, for some reason I can edit and save the daemon.g without renaming it at all. I just edit it on the iterface, save it and it is being accepted...

                    That has been my experience as well.

                    Frederick

                    Printers: a E3D MS/TC setup and a RatRig Hybrid. Using Duet 3 hardware running 3.4.6

                    1 Reply Last reply Reply Quote 0
                    • DonStaufferundefined
                      DonStauffer @chrishamm
                      last edited by

                      @chrishamm What happens if, for example, you have the loop set for a much higher value, say, 100 iterations? I'm asking to understand how the daemon.g file works, so I can make good decisions on how to use it.

                      For example, let's say you set it to 100. The file gets run every 10 seconds, so what happens if it's still running 10 seconds after it was run, due to the loop? Will a second instance run, or does the 10 seconds not even start until the original run ends? The former would get messy memory wise; the latter would mean it wouldn't run every 10 seconds, but instead every 10 seconds plus how long it takes to run. Or, does it "know" it's already running and skip the trigger? That would make the period between runs unpredictable.

                      Also, what's the best way for it to check whether there's a print job running at the moment, so I can write code to only execute during a job?

                      gloomyandyundefined 1 Reply Last reply Reply Quote 0
                      • gloomyandyundefined
                        gloomyandy @DonStauffer
                        last edited by

                        @DonStauffer said in Can't edit/save daemon.g that contains a 1 sec loop.:

                        Also, what's the best way for it to check whether there's a print job running at the moment, so I can write code to only execute during a job?

                        Take a look at the object model documentaton: https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation in particular the state.status it probably has what you need.

                        DonStaufferundefined 1 Reply Last reply Reply Quote 0
                        • dc42undefined
                          dc42 administrators @Tinchus
                          last edited by

                          @Tinchus said in Can't edit/save daemon.g that contains a 1 sec loop.:

                           if global.runDaemon = true
                                 while true
                                      mycode
                                      G4 S2
                          

                          Use this instead:

                          while global.runDaemon
                                 mycode
                                 G4 S2
                          

                          Duet WiFi hardware designer and firmware engineer
                          Please do not ask me for Duet support via PM or email, use the forum
                          http://www.escher3d.com, https://miscsolutions.wordpress.com

                          1 Reply Last reply Reply Quote 0
                          • DonStaufferundefined
                            DonStauffer @gloomyandy
                            last edited by

                            @gloomyandy That may work, but it does raise questions:

                            1. If state.status is "busy", does that imply a job is running, or is it impossible to tell whether maybe it's just executing a G1 from the console, for instance? Would you have to wait for it not to be busy to determine whether there's a job running?

                            2. Does running a macro count as "processing" or is that status only when an actual print job is running?

                            Put another way, what would the test be for simply whether a job is running/unfinished or not, regardless of what else exactly is happening at the time?

                            dc42undefined 1 Reply Last reply Reply Quote 0
                            • dc42undefined
                              dc42 administrators @DonStauffer
                              last edited by dc42

                              @DonStauffer state.status is "processing" only while a job is running from SD card. It's still "processing" even if the job calls a macro.

                              Duet WiFi hardware designer and firmware engineer
                              Please do not ask me for Duet support via PM or email, use the forum
                              http://www.escher3d.com, https://miscsolutions.wordpress.com

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              Unless otherwise noted, all forum content is licensed under CC-BY-SA