From owner-svn-src-all@FreeBSD.ORG Thu Mar 17 17:29:47 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 368E5106564A; Thu, 17 Mar 2011 17:29:47 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 28E678FC15; Thu, 17 Mar 2011 17:29:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2HHTlYu034217; Thu, 17 Mar 2011 17:29:47 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2HHTlSq034215; Thu, 17 Mar 2011 17:29:47 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201103171729.p2HHTlSq034215@svn.freebsd.org> From: John Baldwin Date: Thu, 17 Mar 2011 17:29:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r219717 - head/usr.sbin/mfiutil X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2011 17:29:47 -0000 Author: jhb Date: Thu Mar 17 17:29:46 2011 New Revision: 219717 URL: http://svn.freebsd.org/changeset/base/219717 Log: Add more details to the 'show battery' command including more raw capacity values, charge cycle count, temperature, and more detailed status. Reviewed by: bz, emaste (older version) MFC after: 1 week Modified: head/usr.sbin/mfiutil/mfi_show.c Modified: head/usr.sbin/mfiutil/mfi_show.c ============================================================================== --- head/usr.sbin/mfiutil/mfi_show.c Thu Mar 17 16:35:37 2011 (r219716) +++ head/usr.sbin/mfiutil/mfi_show.c Thu Mar 17 17:29:46 2011 (r219717) @@ -138,8 +138,9 @@ show_battery(int ac, char **av) { struct mfi_bbu_capacity_info cap; struct mfi_bbu_design_info design; + struct mfi_bbu_status stat; uint8_t status; - int error, fd; + int comma, error, fd; if (ac != 1) { warnx("show battery: extra arguments"); @@ -171,16 +172,57 @@ show_battery(int ac, char **av) return (error); } + if (mfi_dcmd_command(fd, MFI_DCMD_BBU_GET_STATUS, &stat, sizeof(stat), + NULL, 0, NULL) < 0) { + warn("Failed to get status"); + return (errno); + } + printf("mfi%d: Battery State:\n", mfi_unit); - printf(" Manufacture Date: %d/%d/%d\n", design.mfg_date >> 5 & 0x0f, + printf(" Manufacture Date: %d/%d/%d\n", design.mfg_date >> 5 & 0x0f, design.mfg_date & 0x1f, design.mfg_date >> 9 & 0xffff); - printf(" Serial Number: %d\n", design.serial_number); - printf(" Manufacturer: %s\n", design.mfg_name); - printf(" Model: %s\n", design.device_name); - printf(" Chemistry: %s\n", design.device_chemistry); - printf(" Design Capacity: %d mAh\n", design.design_capacity); - printf(" Design Voltage: %d mV\n", design.design_voltage); - printf(" Current Charge: %d%%\n", cap.relative_charge); + printf(" Serial Number: %d\n", design.serial_number); + printf(" Manufacturer: %s\n", design.mfg_name); + printf(" Model: %s\n", design.device_name); + printf(" Chemistry: %s\n", design.device_chemistry); + printf(" Design Capacity: %d mAh\n", design.design_capacity); + printf(" Full Charge Capacity: %d mAh\n", cap.full_charge_capacity); + printf(" Current Capacity: %d mAh\n", cap.remaining_capacity); + printf(" Charge Cycles: %d\n", cap.cycle_count); + printf(" Current Charge: %d%%\n", cap.relative_charge); + printf(" Design Voltage: %d mV\n", design.design_voltage); + printf(" Current Voltage: %d mV\n", stat.voltage); + printf(" Temperature: %d C\n", stat.temperature); + printf(" Status:"); + comma = 0; + if (stat.fw_status & MFI_BBU_STATE_PACK_MISSING) { + printf(" PACK_MISSING"); + comma = 1; + } + if (stat.fw_status & MFI_BBU_STATE_VOLTAGE_LOW) { + printf("%s VOLTAGE_LOW", comma ? "," : ""); + comma = 1; + } + if (stat.fw_status & MFI_BBU_STATE_TEMPERATURE_HIGH) { + printf("%s TEMPERATURE_HIGH", comma ? "," : ""); + comma = 1; + } + if (stat.fw_status & MFI_BBU_STATE_CHARGE_ACTIVE) { + printf("%s CHARGING", comma ? "," : ""); + comma = 1; + } + if (stat.fw_status & MFI_BBU_STATE_DISCHARGE_ACTIVE) { + printf("%s DISCHARGING", comma ? "," : ""); + } + if (!comma) + printf(" normal"); + printf("\n"); + switch (stat.battery_type) { + case MFI_BBU_TYPE_BBU: + printf(" State of Health: %s\n", + stat.detail.bbu.is_SOH_good ? "good" : "bad"); + break; + } close(fd);