[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

pmlib_request_battery Subroutine

Purpose

Queries and controls the battery status.

Library

PM (Power Management) Library (libpm.a)

Syntax

#include <pmlib.h>
int pmlib_request_battery (cmd, pmb);
int cmd;
pmlib_battery_t *pmb;

Parameters

cmd Determines the action to be taken by the pmlib_request_battery subroutine and is one of the following values:
PMLIB_QUERY_BATTERY
Queries the battery state.
PMLIB_DISCHARGE_BATTERY
Discharges the battery.
pmb Points to the following pmlib_battery_t structure:
typedef struct _pmlib_battery {
   int attribute;          /*battery attribute*/
   int capacity;           /*battery capacity*/
   int remain;             /*current remain capacity*/
   int refresh_discharge_capacity;
   int refresh_discharge_time; /*discharge time*/
   int full_change_count;
} pmlib_battery_t;

When cmd is PMLIB_QUERY_BATTERY, the returned pmb.attribute is bit-wise OR of following values:

PMLIB_BATTERY_SUPPORTED Battery is supported.
PMLIB_BATTERY_EXIST Battery exists.
PMLIB_BATTERY_NICD Battery is NiCd
PMLIB_BATTERY_CHARGING Battery is being charged.
PMLIB_BATTERY_DISCHARGING Battery is being discharged.
PMLIB_BATTERY_AC AC adapter is in use.
PMLIB_BATTERY_DC Battery is in use.
PMLIB_BATTERY_REFRESH_REQ Need to refresh battery.

Description

The pmlib_request_battery subroutine queries the battery information or requests to discharge the battery. The pmlib_request_ subroutine can be called by any user.

Return Values

Upon successful completion, PMLIB_SUCCESS is returned. If the pmlib_request_state subroutine fails, PMLIB_ERROR is returned and errno variable is set to an error code.

Error Codes

ESRCH PM daemon is not running.
EINVAL Invalid argument.

Implementation Specifics

The pmlib_request_battery subroutine is part of the Base Operation System (BOS) Runtime.

Related Information

The pmlib_get_event_notice subroutine, pmlib_request_state subroutine, pmlib_request_parameter subroutine, pmlib_register_application subroutine.


[ Previous | Next | Contents | Glossary | Home | Search ]