2023-03-06 00:55:12 +01:00
|
|
|
|
|
|
|
#include <filesystem>
|
2021-07-29 11:35:20 +02:00
|
|
|
#include <iostream>
|
2023-03-06 00:55:12 +01:00
|
|
|
#include <string>
|
2021-07-29 11:35:20 +02:00
|
|
|
|
2023-02-23 23:56:11 +01:00
|
|
|
#include "Watchdog.h"
|
2023-03-06 00:55:12 +01:00
|
|
|
#include "definitions.h"
|
2023-02-23 23:56:11 +01:00
|
|
|
|
2021-07-29 11:35:20 +02:00
|
|
|
/**
|
|
|
|
* @brief This watchdog application uses a FIFO to check whether the OBSW is still running.
|
|
|
|
* It checks whether the OBSW writes to the the FIFO regularly.
|
|
|
|
*/
|
|
|
|
int main() {
|
2023-02-24 01:08:26 +01:00
|
|
|
std::cout << "Starting OBSW watchdog" << std::endl;
|
2023-03-06 00:55:12 +01:00
|
|
|
if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) {
|
|
|
|
std::cout << "Removing " << watchdog::RUNNING_FILE_NAME << std::endl;
|
|
|
|
int result = std::remove(watchdog::RUNNING_FILE_NAME.c_str());
|
|
|
|
if (result != 0) {
|
|
|
|
std::cerr << "file removal failure" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
2023-02-23 23:56:11 +01:00
|
|
|
try {
|
|
|
|
WatchdogTask watchdogTask;
|
|
|
|
int result = watchdogTask.performOperation();
|
|
|
|
if (result != 0) {
|
|
|
|
return result;
|
2021-07-29 11:59:32 +02:00
|
|
|
}
|
2023-02-23 23:56:11 +01:00
|
|
|
} catch (const std::runtime_error& e) {
|
2023-02-24 01:08:26 +01:00
|
|
|
std::cerr << "Run time exception " << e.what() << std::endl;
|
2023-02-23 23:56:11 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
2021-07-29 11:35:20 +02:00
|
|
|
}
|