[Previous] [Contents] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

pm_getattr()

Get the power attributes of a power managed object

Synopsis:

#include <sys/pm.h>

int pm_getattr(pm_hdl_t hdl, 
               pm_power_attr_t *attr);

Arguments:

hdl
A handle to the object obtained via pm_attach().
attr
Pointer to where the power attributes are returned.

Description:

The pm_getattr() function gets the current power attributes of a power managed object.

The current power mode is returned in attr->cur_mode.

If the object is in the process of changing power modes, the new mode will be returned in attr->new_mode.

The number of power modes supported by the object is returned in attr->num_modes. This value can be supplied to pm_getmodes() or pm_modeattr() to retrieve the full list of supported modes.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EBADF
hdl isn't a valid handle.
EFAULT
A fault occurred accessing attr.

Examples:

#include <sys/pm.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
   pm_hdl_t                hdl;
   pm_power_attr_t attr;

   hdl = pm_attach("object", O_RDONLY);
   if (!pm_valid_hdl(hdl)) {
      perror("pm_attach");
      return EXIT_FAILURE;
   }
   
   if (pm_getattr(hdl, &attr) == -1) {
      perror("pm_getattr");
      return EXIT_FAILURE;
   }
   
   printf("Device supports %d modes\n", attr.num_modes);
   printf("cur_mode = 0x%x\n", attr.cur_mode);
   printf("new_mode = 0x%x\n", attr.new_mode);
   return EXIT_SUCCESS;
}

Classification:

Neutrino

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

pm_power_mode_t, pm_attach(), pm_setmode(), pm_getmodes(), pm_modeattr()


[Previous] [Contents] [Next]