Go Down

Topic: use of exit(0) (Read 38066 times) previous topic - next topic

retronet_RIMBA1ZO


not really.
For one millis() and Serial interrupts will still be firing.
Secondly SerialEvent() is still being called by loop.

which it would still do in the example suggested by this person ?
Quote
put it into an infinite loop that doesn't do anything




Thirdly why on earth would you do it that way?

to show my n00bness...

Tom Carpenter

In our examples you will notice the cli() instruction which disables all interrupts. Also, we don't let loop() keep running (so nor will SerialEvent()).
~Tom~

PaulS

Quote
Secondly SerialEvent() is still being called by loop.

Only if the function is defined, and only if there is serial data to process, and only if the end of loop() is actually reached. Calls to exit() make the last part the most unlikely event to actually happen..

Tom Carpenter


Only if the function is defined, and only if there is serial data to process, and only if the end of loop() is actually reached. Calls to exit() make the last part the most unlikely event to actually happen..

You don't know that its not defined. The whole point in a function that is supposed to stop everything is that it stops everything and doesn't leave open the possibility that the user has left executable code that can still be run.
You'll also notice that in that example exit() is not called, but rather he has used a goto; statement to break out of a loop.
~Tom~

Go Up