reset mbed using code every 6 hours

06 Feb 2012

How can I reset mbed at regular intervals(every 6 or 12 hours) using code instead of pushbutton or usb?

06 Feb 2012

In handbook - Timeout.

In search: software reset

extern "C" void mbed_reset();

That's bout it

07 Feb 2012

OK GREAT:

I added code:

Timeout reset_pgm added before main loop

reset_pgm.attach(extern "C" void mbed_reset(), 60.0);added at beginning of main loop to reset mbed every 60 seconds

I get error 29 so I guess I'm missing something very simple.

Appreciate the help!

Thanks

07 Feb 2012

I think you should use ticker and call reset every 6 hours

08 Feb 2012

Hi,

I think that you have not used correctly ticker, because I think that instead of writing it

reset_pgm.attach(extern "C" void mbed_reset(), 60.0);

you should write

reset_pgm.attach(&mbed_reset(), 60.0);

I'm not sure, but try it.

08 Feb 2012

Got error code 20 "mbed_reset is undefined"

Is there a library or something else I have to load??

08 Feb 2012

Is this what you have:

#include "mbed.h"

extern "C" void mbed_reset();

Timeout reset_pgm; 

int main() {

  reset_pgm.attach(&mbed_reset(), 60.0);
}

Some know issues on http://mbed.org/forum/mbed/topic/3045/?page=1#comment-15418

Also see: http://mbed.org/forum/mbed/topic/890/?page=1#comment-4324

08 Feb 2012

Thats what I had and it didn't work so I removed the () from reset_pgm.attach(&mbed_reset(), 60.0);" and now it seems to be working OK.

Thanks for the help;

Is there a time limit for the time period; can I use timeout for a 6 hour time period???

08 Feb 2012

yes, need to delete the ()

The API http://mbed.org/handbook/Timeout states that time is in seconds and in float format. Should work, but you may have to test it. Anyhow, you can always use a 3600s Timeout, and on callback test for 6th call before you do a reset..

09 Feb 2012

Lately i've been having issues with timeout function, but that shouldn't be a problem anymore.

You could use ticker, but that keeps calling the reset after the specified time period. But when you reset, that defeats the purpose.

Lerche

27 May 2014
  1. include "mbed.h"

extern "C" void mbed_reset();

Timeout reset_pgm;

int main() {

reset_pgm.attach(&mbed_reset, X); }

X = seconds for the timeout (its a float so e.g. 60.0 for one minute or 3600.0 for one hour)