Date: Wed, 2 Oct 2002 10:17:10 +0200 From: Mark Santcroos <marks@ripe.net> To: Craig Rodrigues <rodrigc@attbi.com> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: ACPI programming under FreeBSD? Message-ID: <20021002081710.GA842@laptop.6bone.nl> In-Reply-To: <20021001162300.A31745@attbi.com> References: <20021001162300.A31745@attbi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <stdio.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021002081710.GA842>