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 object
#include <sys/pm.h> int pm_getattr(pm_hdl_t hdl, pm_power_attr_t *attr);
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.
#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; }
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
pm_power_mode_t, pm_attach(), pm_setmode(), pm_getmodes(), pm_modeattr()