| ![[Previous]](../prev.gif) | ![[Contents]](../contents.gif) | ![[Next]](../next.gif) | 
|  | This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. | 
Get the power modes and capabilities supported by a power managed device
#include <sys/pm.h>
int iopower_modeattr(int filedes, 
                     pmd_mode_attr_t *modes, 
                     int nmodes);
libpm
The iopower_modeattr() is used to get a list of the power modes supported by a power managed device.
For each mode, the pmd_mode_attr_t contains:
The number of modes supported by the device, or -1 (errno is set).
#include <sys/pm.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <alloca.h>
int
main(void)
{
  int  fd;
  int  i;
  int  nmode;
  pmd_mode_attr_t *modes;
  fd = open("/dev/device", O_RDONLY);
  if (fd == -1) {
     perror("open");
     return EXIT_FAILURE;
  }
  nmode = iopower_modeattr(fd, 0, 0);
  if (nmode < 0) {
     perror("iopower_modeattr");
     return EXIT_FAILURE;
  }
  
  printf("Device supports %d modes:", nmode);
  modes = alloca(nmode * sizeof(*mode));
  if (modes == 0) {
     perror("alloca");
     return EXIT_FAILURE;
  }
  nmode = iopower_modeattr(fd, modes, nmode);
  if (nmode < 0) {
     perror("iopower_modeattr");
     return EXIT_FAILURE;
  }
  
  for (i = 0; i < nmode; i++) {
      printf("%d: mode=0x%x flags=0x%x\n", 
      i, modes[i].mode,
      modes[i].flags);
  }
  
  return EXIT_SUCCESS;
}
| Safety: | |
|---|---|
| Cancellation point | Yes | 
| Interrupt handler | No | 
| Signal handler | Yes | 
| Thread | Yes | 
pm_power_mode_t, pmd_mode_attr_t, iopower_getattr(), iopower_setmode(), iopower_getmodes()
| ![[Previous]](../prev.gif) | ![[Contents]](../contents.gif) | ![[Next]](../next.gif) |