Skip to content

How to use watchdog? #324

Closed
Closed
@jerabaul29

Description

@jerabaul29

I am trying to use the watchdog in an Mbed-OS way, but I am having problems. Any idea how to fix this?

// inspired from https://os.mbed.com/docs/mbed-os/v6.6/apis/watchdog.html

#include "mbed.h"

const uint32_t TIMEOUT_MS = 5000;

void setup() {
  // put your setup code here, to run once:

}

int main()
{
    Serial.begin(57600);
    Serial.println(F("Start"));
    Serial.end();
    
    Watchdog &watchdog = Watchdog::get_instance();
    watchdog.start(TIMEOUT_MS);

    while (true) {
      Serial.begin(57600);

        if (true){
          Serial.print(F("reset watchdog"));
          Watchdog::get_instance().kick();
        }
        else{
          Serial.println(F("do not reset watchdog; will bite in a few iterations..."));
        }
        
        ThisThread::sleep_for(TIMEOUT_MS / 10);
        
      Serial.end();
    }
}

Does not compile:

'Watchdog' was not declared in this scope

I also tried with a:

    rtos::Watchdog &watchdog = rtos::Watchdog::get_instance();

similar to what is used for threads in the example provided, but with no success:

'Watchdog' is not a member of 'rtos'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions