From d3013b9a091e54b4cf2a3049d59d84884bcb607c Mon Sep 17 00:00:00 2001 From: Kamala Narasimhan Date: Thu, 5 Mar 2009 23:02:54 -0500 Subject: [PATCH] Set battery charging/discharging/charged bits appropriately. --- tools/xenpmd/xenpmd.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/xenpmd/xenpmd.c b/tools/xenpmd/xenpmd.c index 507f8f0..1edf4b5 100644 --- a/tools/xenpmd/xenpmd.c +++ b/tools/xenpmd/xenpmd.c @@ -221,13 +221,21 @@ void set_attribute_battery_status(char *attrib_name, char *attrib_value, struct battery_status *status) { - if ( strstr(attrib_name, "charging state") ) + if ( strstr(attrib_name, "charging state") ) { - /* Check this, below is half baked */ - if ( strstr(attrib_value, "charged") ) - status->state = 0; - else - status->state = 1; + if ( strstr(attrib_value, "charging/discharging") ) + status->state |= 0x3; + else if ( strstr(attrib_value, "discharging") ) + status->state |= 0x1; + else if ( strstr(attrib_value, "charging") ) + status->state |= 0x2; + return; + } + + if ( strstr(attrib_name, "capacity state") ) + { + if ( strstr(attrib_value, "ok") ) + status->state |= 4; return; } -- 2.39.5