Pages: [1]   Go Down
Author Topic: Effect of Returning from loop()  (Read 915 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

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

Logged

Offline Offline
God Member
*****
Karma: 19
Posts: 781
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
God Member
*****
Karma: 19
Posts: 781
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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().
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 303
Posts: 26354
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes Please.  and Thank you
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: