[Previous] [Contents] [Next]

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

iopower_getattr()

Get the power attributes of a power managed device

Synopsis:

#include <sys/pm.h>
int iopower_getattr(int filedes, pm_power_attr_t *attr);

Arguments:

filedes
A file descriptor to the device special file.
attr
Pointer to where the power attributes are returned.

Library:

libpm

Description:


Note:

The iopower_getattr() function replaces pm_get_power() that has been deprecated.


The iopower_getattr() gets the current power attributes of a power managed device.

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

If the device 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 device is returned in attr->num_modes. This value can be supplied to iopower_getmodes() or iopower_modeattr() to retrieve the full list of supported modes.

Returns:

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

Errors:

EBADF
filedes is not a valid file descriptor.
EFAULT
A fault occurred accesing modes.
ENOSYS
The device specified by filedes doesn't implement power management.

Examples:

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

   fd = open("/dev/device", O_RDONLY);
   if (fd == -1) {
      perror("open");
      return EXIT_FAILURE;
    }
    if (iopower_getattr(fd, &attr) == -1) {
       perror("iopower_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, iopower_setmode(), iopower_getmodes(), iopower_modeattr()


[Previous] [Contents] [Next]