SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
Loading...
Searching...
No Matches
callbacks.cpp
Go to the documentation of this file.
1/*
2 * SatNOGS-COMMS MCU software
3 *
4 * Copyright (C) 2024, Libre Space Foundation <http://libre.space>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * SPDX-License-Identifier: GNU General Public License v3.0 or later
20 */
21
22#include "callbacks.hpp"
23#include <zephyr/device.h>
24#include <zephyr/drivers/watchdog.h>
25#include <zephyr/kernel.h>
26#include <zephyr/logging/log.h>
27#include <zephyr/sys/reboot.h>
28#include <zephyr/task_wdt/task_wdt.h>
29
30/* Declare the file as part of the original module in main.cpp */
31LOG_MODULE_DECLARE(satnogscomms);
32
33namespace satnogs::comms
34{
35
36void
37task_wdt_callback(int channel_id, void *user_data)
38{
39 k_msleep(1000);
40 LOG_ERR("Task watchdog channel %d callback, thread: %s\n", channel_id,
41 k_thread_name_get((k_tid_t)user_data));
42 k_msleep(1000);
43 /*
44 * If the issue could be resolved, call task_wdt_feed(channel_id) here
45 * to continue operation.
46 *
47 * Otherwise we can perform some cleanup and reset the device.
48 */
49 LOG_ERR("Resetting device...\n");
50 k_msleep(1000);
51 sys_reboot(SYS_REBOOT_COLD);
52}
53} // namespace satnogs::comms
LOG_MODULE_DECLARE(satnogscomms)
void task_wdt_callback(int channel_id, void *user_data)
Definition callbacks.cpp:37