Go Down

Topic: Effect of Returning from loop() (Read 953 times) previous topic - next topic

sev1962

If I return from the required loop()   function ,  Does the System automatically re run the function, or will the system stall.

I have a piece of code in a new loop1()  using Scheduler.   The code calls a return; on any config failures.   I would hope the loop1() will just repeat.

Is this a correct assumption?


sev1962

I believe I got my answer for main.cpp
i
nt main(void)
{
   init();

#if defined(USBCON)
   USBDevice.attach();
#endif
   
   setup();
   
   for (;;) {
      loop();

      if (serialEventRun) serialEventRun();
   }
       
   return 0;
}


Delta_G

Right.  loop() will get called over and over.  Your new function loop1() will only be called if you call it.  Returning from it will return to wherever you called it from. 

sev1962

Ahh. But with the Due, There is a Scheduler library.   This loop1 is a secondary loop. ( Multitasking)

Will this loop be  called again like the Main loop?

Delta_G

Oh, you didn't say Due.  I don't know about Due.

But if it uses that same main.cpp then I would assume no since that main() doesn't ever call anything called loop1().

sev1962

Sorry for not being clear about the Due.

I would hope that the Scheduler library would handle the loop.

I will dig into this.
Thanks for your reply.


AWOL

Quote
Sorry for not being clear about the Due.
The Due has its own forum section.
Would you like me to move this thread there?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

sev1962


sev1962

Ran some tests at it appears that the secondary loops do in fact repeat  after a return.

Go Up