This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Get the power attributes of a power managed device
#include <sys/pm.h> int iopower_getattr(int filedes, pm_power_attr_t *attr);
libpm
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.
#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; }
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
pm_power_mode_t, iopower_setmode(), iopower_getmodes(), iopower_modeattr()