Firmware
Functions | Variables
px4_shutdown.h File Reference

Power-related API. More...

#include <stdbool.h>

Go to the source code of this file.

Functions

__EXPORT int px4_register_shutdown_hook (shutdown_hook_t hook)
 Register a method that should be called when powering off (and also on reboot). More...
 
__EXPORT int px4_unregister_shutdown_hook (shutdown_hook_t hook)
 Unregister a shutdown hook. More...
 
__EXPORT int px4_shutdown_request (bool reboot, bool to_bootloader)
 Request the system to shut down or reboot. More...
 
__EXPORT int px4_shutdown_lock (void)
 Grab the shutdown lock. More...
 
__EXPORT int px4_shutdown_unlock (void)
 Release the shutdown lock. More...
 

Variables

__BEGIN_DECLS typedef bool(* shutdown_hook_t )(void)
 Shutdown hook callback method (. More...
 

Detailed Description

Power-related API.

Function Documentation

§ px4_register_shutdown_hook()

__EXPORT int px4_register_shutdown_hook ( shutdown_hook_t  hook)

Register a method that should be called when powering off (and also on reboot).

Parameters
hookcallback 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()

__EXPORT 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()

__EXPORT 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
    rebootperform a reboot instead of a shutdown
    to_bootloaderreboot into bootloader mode (only used if reboot is true)
    Returns
    0 on success, <0 on error

§ px4_shutdown_unlock()

__EXPORT int px4_shutdown_unlock ( void  )

Release the shutdown lock.

Returns
0 on success, <0 on error

§ px4_unregister_shutdown_hook()

__EXPORT int px4_unregister_shutdown_hook ( shutdown_hook_t  hook)

Unregister a shutdown hook.

Parameters
hookcallback method to be removed
Returns
0 on success, <0 on error

Variable Documentation

§ shutdown_hook_t

__BEGIN_DECLS typedef bool(* shutdown_hook_t) (void)

Shutdown hook callback method (.

See also
px4_register_shutdown_hook()).
Returns
true if it's ok to shutdown, false if more time needed for cleanup