Application Watchdog test results in "assertion failure"

I am attempting to implement the application watchdog in a project that will be located in a hard to reach location and needs to be able to run independently for long periods of time. After adding the necessary code to my application and testing it I experienced an error where the photon would power up, connect to the cloud and breathe cyan as usual. But when the watchdog was triggered, rather than resetting the photon would issue an SOS signal followed by 10 blinks meaning “assertion error”. Suspecting something weird was going on with an interaction between the watchdog and my code, I wrote a sketch to test just the watchdog (see below). This program behaves like expected up until the watchdog is triggered. Like in my first sketch, rather than resetting the photon blinks SOS followed by 10 blinks aka “assertion failure”. I do not know what an assertion failure is but I tried running particle device doctor on it to no avail. Does anyone have any idea why this is happening? Any help is appreciated.

ApplicationWatchdog wd(30000, System.reset);

void setup() {}

void loop() {
  while (1) {
    delay(10); // should prevent the wd from being kicked
  }
}

IIRC, this test code shouldn’t trigger the Application Watchdog since you are calling delay() which in turn calls Particle.process() every accumulated 1000ms of delay time and this in turn does tickle the watchdog.

What system version are you running this on?

This is running on 0.7.0. What could be causing the assertion failure if not the watchdog? It seems like it must have something to do with the watchdog.

I have updated the code to this but am still encountering the assertion error. It behaves as expected, breathing cyan for a bit before losing its cloud connection and switching to breathing green, but it still issues the SOS.

ApplicationWatchdog wd(30000, System.reset);

void setup() 
{

}

void loop() 
{
    int x;
    while (1) 
    {
        x++;
    }
}

That indeed is odd. I’ve even tried your code with SYSTEM_MODE(SEMI_AUTOMATIC) and with and without SYSTEM_THREAD(ENABLED) just to make sure the cloud stuff doesn’t cause troubles and it actually is crashing and after the reset the devices doesn’t come back to life either.
Only a RESET helps.

@rickkas7, seems like a regression?


Update:
With ApplicationWatchdog wd(10000, System.reset, 1536); (three times the default stack size of 512) it works. Obviously System.reset() does now require a lot more stack space when called from the AWD.


Opened a issue on GitHub

3 Likes

Upping the stack size works. Thanks for the help!

1 Like