diff options
author | imp <imp@FreeBSD.org> | 2004-11-24 16:02:20 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2004-11-24 16:02:20 +0000 |
commit | 00db5ac668a23296484b1f5de865bcf8360b479f (patch) | |
tree | f7730247843e4475284b90dc971aebe05c8b6868 /usr.sbin/acpi/acpiconf | |
parent | d9d5c6d6b74aaa2f2f9c921becaab7c8668b8662 (diff) | |
download | FreeBSD-src-00db5ac668a23296484b1f5de865bcf8360b479f.zip FreeBSD-src-00db5ac668a23296484b1f5de865bcf8360b479f.tar.gz |
o Report charge/discharge rate and remaining capacity in the proper
units (as specified in _BIF). (noted by Bruno Ducrot)
o In looking in the standard, if the cap numbers are 0xffffffff, then acpi
is reporting unknown for that field. Report unknown numbers properly.
o Update the state to reflect charging, discharging and critical.
Diffstat (limited to 'usr.sbin/acpi/acpiconf')
-rw-r--r-- | usr.sbin/acpi/acpiconf/acpiconf.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/usr.sbin/acpi/acpiconf/acpiconf.c b/usr.sbin/acpi/acpiconf/acpiconf.c index 53f8604..c475bea 100644 --- a/usr.sbin/acpi/acpiconf/acpiconf.c +++ b/usr.sbin/acpi/acpiconf/acpiconf.c @@ -83,6 +83,9 @@ acpi_sleep(int sleep_type) return (0); } +/* should be a acpi define, but doesn't appear to be */ +#define UNKNOWN_CAP 0xffffffff + static int acpi_battinfo(int num) { @@ -101,11 +104,21 @@ acpi_battinfo(int num) else pwr_units = "mAh"; - printf("Design capacity:\t%d %s\n", battio.bif.dcap, pwr_units); - printf("Last full capacity:\t%d %s\n", battio.bif.lfcap, pwr_units); + if (battio.bif.dcap == UNKNOWN_CAP) + printf("Design capacity:\tUnknown\n"); + else + printf("Design capacity:\t%d %s\n", battio.bif.dcap, pwr_units); + if (battio.bif.lfcap == UNKNOWN_CAP) + printf("Last full capacity:\tUnknown\n"); + else + printf("Last full capacity:\t%d %s\n", battio.bif.lfcap, + pwr_units); printf("Technology:\t\t%s\n", battio.bif.btech == 0 ? "primary (non-rechargeable)" : "secondary (rechargeable)"); - printf("Design voltage:\t\t%d mV\n", battio.bif.dvol); + if (battio.bif.dvol == UNKNOWN_CAP) + printf("Design voltage:\t\tUnknown\n"); + else + printf("Design voltage:\t\t%d mV\n", battio.bif.dvol); printf("Capacity (warn):\t%d %s\n", battio.bif.wcap, pwr_units); printf("Capacity (low):\t\t%d %s\n", battio.bif.lcap, pwr_units); printf("Low/warn granularity:\t%d %s\n", battio.bif.gra1, pwr_units); @@ -120,10 +133,28 @@ acpi_battinfo(int num) err(EX_IOERR, "get battery info (%d) failed", num); if (battio.bst.state != ACPI_BATT_STAT_NOT_PRESENT) { - printf("State:\t\t\tPresent\n"); - printf("Present Rate:\t\t%d mWh\n", battio.bst.rate); - printf("Remaining Capacity:\t%d mWh\n", battio.bst.cap); - printf("Volt:\t\t\t%d mV\n", battio.bst.volt); + printf("State:\t\t\t"); + if (battio.bst.state & ACPI_BATT_STAT_CRITICAL) + printf("CRITICAL "); + if (battio.bst.state & ACPI_BATT_STAT_DISCHARG) + printf("Discharging "); + if (battio.bst.state & ACPI_BATT_STAT_CHARGING) + printf("Charging"); + printf("\n"); + if (battio.bst.rate == UNKNOWN_CAP) + printf("Present Rate:\t\tUnknown\n"); + else + printf("Present Rate:\t\t%d %s\n", battio.bst.rate, + pwr_units); + if (battio.bst.cap == UNKNOWN_CAP) + printf("Remaining Capacity:\tUnknown\n"); + else + printf("Remaining Capacity:\t%d %s\n", battio.bst.cap, + pwr_units); + if (battio.bst.volt == UNKNOWN_CAP) + printf("Volt:\t\t\tUnknown\n"); + else + printf("Volt:\t\t\t%d mV\n", battio.bst.volt); } else { printf("State:\t\t\tNot Present\n"); } |