[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_getmodes()

Get the power modes supported by a power managed object

Synopsis:

#include <sys/pm.h>

int pm_getmodes(pm_hdl_t hdl, 
                pm_power_mode_t *modes,
		int nmodes);

Arguments:

hdl
Handle to the object obtained via pm_attach().
modes
A pointer to where the list of modes are returned.
nmodes
The number of modes to be returned.

Library:

libpm

Description:

The pm_getmodes() function call is used to get the list of power modes supported by a power managed object.

Returns:

If successful, pm_getmodes() returns the number of modes supported by the object.

If an error occurs, it returns -1 and errno is set.

Errors:

EBADF
hdl is not a valid handle.
EFAULT
A fault occurred accessing to modes.

Examples:

#include <sys/pm.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
   pm_hdl_t hdl;
   int      i;
   
   int                             nmode;
   pm_power_mode_t *modes;

   hdl = pm_attach("object", O_RDONLY);
   if (!pm_valid_hdl(hdl)) {
      perror("pm_attach");
      return EXIT_FAILURE;
   }

   nmode = pm_getmodes(fd, 0, 0);
   if (nmode < 0) {
      perror("pm_getmodes");
      return EXIT_FAILURE;
   }
   
   printf("Device supports %d modes:", nmode);

   modes = alloca(nmode * sizeof(*modes));
   
   if (modes == 0) {
      perror("alloca");
      return EXIT_FAILURE;
   }

   nmode = pm_getmodes(fd, modes, nmode);
   if (nmode < 0) {
   perror("iopower_getmodes");
   return EXIT_FAILURE;
   
   }
   
   for (i = 0; i < nmode; i++) {
       printf("%d: mode=0x%x\n", i, modes[i]);
   }
   
   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_getattr(), pm_setmode() pm_modeattr()


[Previous] [Contents] [Next]