-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add the ability to be called back when the device is about to reset #1012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* yield (so pretty much don't call Arduino code). And god help you if | ||
* it crashes. | ||
*/ | ||
void installCustomCrashCallback( CrashCallback ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the best place I could find to allow installing the callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion is to install custom crash handler by overriding some weak
function, which defaults to no-op.
On Thu, Nov 12, 2015 at 9:56 PM, Carl Pacey notifications@github.com
wrote:
In cores/esp8266/Esp.h
#1012 (comment):@@ -131,6 +133,13 @@ class EspClass {
bool eraseConfig();inline uint32_t getCycleCount();
/**
\* Be very careful in your callback. Don't call anything that could
\* yield (so pretty much don't call Arduino code). And god help you if
\* it crashes.
*/
void installCustomCrashCallback( CrashCallback );
This was the best place I could find to allow installing the callback.
—
Reply to this email directly or view it on GitHub
https://github.com/esp8266/Arduino/pull/1012/files#r44698297.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know about that feature, that's way cleaner. I'll make that change, thanks!
Caveats: - You have to be very careful in your callback. - On Adafruit Huzzah, I only actually get called for Exceptions and Soft WDT resets.
extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) { | ||
} | ||
|
||
extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've aped the style used elsewhere in this project, though I must admit I don't know the reason for the alias (my guess is that it makes for less confusion when looking at stack dumps).
Apologies for all the churn. I'll try to keep that down in the future. |
Add the ability to be called back when the device is about to reset
Attempt to address #1011. Feedback is desired, because it's not the cleanest code.
Caveats: