From owner-freebsd-hackers Wed Oct 2 2: 4:27 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF37937B401 for ; Wed, 2 Oct 2002 02:04:24 -0700 (PDT) Received: from birch.ripe.net (birch.ripe.net [193.0.1.96]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0CA9E43E42 for ; Wed, 2 Oct 2002 02:04:24 -0700 (PDT) (envelope-from marks@ripe.net) Received: from laptop.6bone.nl (cow.ripe.net [193.0.1.239]) by birch.ripe.net (8.12.5/8.11.6) with SMTP id g9294K95004209; Wed, 2 Oct 2002 11:04:20 +0200 Received: (nullmailer pid 872 invoked by uid 1000); Wed, 02 Oct 2002 08:17:10 -0000 Date: Wed, 2 Oct 2002 10:17:10 +0200 From: Mark Santcroos To: Craig Rodrigues Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: ACPI programming under FreeBSD? Message-ID: <20021002081710.GA842@laptop.6bone.nl> References: <20021001162300.A31745@attbi.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="KsGdsel6WgEHnImy" Content-Disposition: inline In-Reply-To: <20021001162300.A31745@attbi.com> User-Agent: Mutt/1.4i X-Handles: MS6-6BONE, MS18417-RIPE X-RIPE-Spam-Status: NONE ; -1132 X-RIPE-Spam-Level: Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I have a very simple program that does exactly this using sysctl's. Find it attached. ACPI developers, there is alot more information available in the kernel about ACPI that we don't export to userland yet. Do you think we should do that using more sysctl's or should we implement some ioctl's on /dev/acpi to retrieve the information? Mark On Tue, Oct 01, 2002 at 04:23:00PM -0400, Craig Rodrigues wrote: > Hi, > > I am interested in retrieving power statistics type of information from a > system running FreeBSD. I am interested in information such as: > power consumed, temperature, percentage of battery available, etc. > > Is it possible to do this with ACPI, and if so, are there any > examples of how to gather this information at the user-level? > > How stable is ACPI support in -STABLE and -CURRENT for this > kind of work? > > Thanks. > -- > Craig Rodrigues > http://www.gis.net/~craigr > rodrigc@attbi.com > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message -- Mark Santcroos RIPE Network Coordination Centre http://www.ripe.net/home/mark/ New Projects Group/TTM --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="acpistat.c" #define KELVIN_TO_CELSIUS(t) ((t-2732+5)/10) #include int main() { int ret; int intbuf; size_t len; ret=sysctlbyname("hw.acpi.thermal.tz0.temperature",&intbuf,&len,NULL,0); if(ret==0) printf("tz0 temperarture: %d C\n",KELVIN_TO_CELSIUS(intbuf)); ret=sysctlbyname("hw.acpi.thermal.tz0._CRT",&intbuf,&len,NULL,0); if(ret==0) printf("tz0 crit temperarture: %d C\n",KELVIN_TO_CELSIUS(intbuf)); ret=sysctlbyname("hw.acpi.acline",&intbuf,&len,NULL,0); if(ret==0) printf("AC Line status: %s\n",intbuf?"online":"offline"); ret=sysctlbyname("hw.acpi.battery.units",&intbuf,&len,NULL,0); if(ret==0) printf("Number of battery units: %d\n",intbuf); ret=sysctlbyname("hw.acpi.battery.state",&intbuf,&len,NULL,0); if(ret==0) printf("Battery state: %d\n",intbuf); ret=sysctlbyname("hw.acpi.battery.life",&intbuf,&len,NULL,0); if(ret==0) printf("Remaining battery life: %d%%\n",intbuf); ret=sysctlbyname("hw.acpi.battery.time",&intbuf,&len,NULL,0); if(ret==0) printf("Remaining battery time: %d:%d\n",intbuf/60,intbuf%60); printf("crit: %d\n",KELVIN_TO_CELSIUS(3732)); return(0); } --KsGdsel6WgEHnImy-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message