Implementation of the API declared in px4_shutdown.h.
More...
#include <board_config.h>
#include <px4_workqueue.h>
#include <px4_shutdown.h>
#include <px4_tasks.h>
#include <px4_log.h>
#include <stdint.h>
#include <errno.h>
#include <pthread.h>
|
#define | MODULE_NAME "shutdown" |
|
#define | SHUTDOWN_ARG_IN_PROGRESS (1<<0) |
|
#define | SHUTDOWN_ARG_REBOOT (1<<1) |
|
#define | SHUTDOWN_ARG_TO_BOOTLOADER (1<<2) |
|
Implementation of the API declared in px4_shutdown.h.
§ px4_register_shutdown_hook()
Register a method that should be called when powering off (and also on reboot).
- Parameters
-
hook | callback method. It must not block, but return immediately. When the system is requested to shutdown, the registered hooks will be called regularily until either all of them return true, or a timeout is reached. |
- Returns
- 0 on success, <0 on error
§ px4_shutdown_lock()
int px4_shutdown_lock |
( |
void |
| ) |
|
Grab the shutdown lock.
It will prevent the system from shutting down until the lock is released. It is safe to call this recursively.
- Returns
- 0 on success, <0 on error
§ px4_shutdown_request()
int px4_shutdown_request |
( |
bool |
reboot, |
|
|
bool |
to_bootloader |
|
) |
| |
Request the system to shut down or reboot.
Note the following:
- The system might not support to shutdown (or reboot). In that case -EINVAL will be returned.
- The system might not shutdown immediately, so expect this method to return even on success.
- Parameters
-
reboot | perform a reboot instead of a shutdown |
to_bootloader | reboot into bootloader mode (only used if reboot is true) |
- Returns
- 0 on success, <0 on error
§ px4_shutdown_unlock()
int px4_shutdown_unlock |
( |
void |
| ) |
|
Release the shutdown lock.
- Returns
- 0 on success, <0 on error
§ px4_unregister_shutdown_hook()
Unregister a shutdown hook.
- Parameters
-
hook | callback method to be removed |
- Returns
- 0 on success, <0 on error