From owner-freebsd-ports-bugs@FreeBSD.ORG Thu Aug 5 16:00:45 2004 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 296A516A4CE for ; Thu, 5 Aug 2004 16:00:45 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 14CD543D3F for ; Thu, 5 Aug 2004 16:00:45 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i75G0inl029003 for ; Thu, 5 Aug 2004 16:00:44 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i75G0i5E028997; Thu, 5 Aug 2004 16:00:44 GMT (envelope-from gnats) Resent-Date: Thu, 5 Aug 2004 16:00:44 GMT Resent-Message-Id: <200408051600.i75G0i5E028997@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Roman Bogorodskiy Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3F59616A4CE for ; Thu, 5 Aug 2004 15:52:14 +0000 (GMT) Received: from mx1.mail.ru (mx1.mail.ru [194.67.23.121]) by mx1.FreeBSD.org (Postfix) with ESMTP id 08D2343D45 for ; Thu, 5 Aug 2004 15:52:14 +0000 (GMT) (envelope-from bogorodskiy@inbox.ru) Received: from [194.186.150.66] (port=49174 helo=inbox.ru) by mx1.mail.ru with esmtp id 1BskXL-000D0o-00 for FreeBSD-gnats-submit@freebsd.org; Thu, 05 Aug 2004 19:52:12 +0400 Message-Id: Date: Thu, 05 Aug 2004 19:52:12 +0400 From: Roman Bogorodskiy To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: ports/70039: [ maintainer ] sysutils/torsmo: add some acpi stuff X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Roman Bogorodskiy List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2004 16:00:45 -0000 >Number: 70039 >Category: ports >Synopsis: [ maintainer ] sysutils/torsmo: add some acpi stuff >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: maintainer-update >Submitter-Id: current-users >Arrival-Date: Thu Aug 05 16:00:44 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Roman Bogorodskiy >Release: FreeBSD 5.2.1-RELEASE-p9 i386 >Organization: >Environment: System: FreeBSD lame.novel.ru 5.2.1-RELEASE-p9 FreeBSD 5.2.1-RELEASE-p9 #11: Thu Aug 5 07:58:46 MSD 2004 root@lame.novel.ru:/usr/obj/usr/src/sys/NOV i386 >Description: Add ACPI support patch by Anton Karpov with some modifications. >How-To-Repeat: >Fix: diff -ruN torsmo.orig/files/freebsd.c torsmo/files/freebsd.c --- torsmo.orig/files/freebsd.c Thu Aug 5 19:40:18 2004 +++ torsmo/files/freebsd.c Thu Aug 5 19:41:06 2004 @@ -28,6 +28,7 @@ void net_init(); #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) +#define KELVTOC(x) ((x - 2732) / 10.0) static int getsysctl(char *name, void *ptr, size_t len) { @@ -291,14 +292,27 @@ } double get_acpi_temperature(int fd) { - double temp; + double temp; - temp = 0; - - return temp; + if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) { + (void)fprintf(stderr, "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n"); + temp = -1.0; + } + + return KELVTOC(temp); } void get_battery_stuff(char *buf, unsigned int n, int b) { + int battime; + + if (GETSYSCTL("hw.acpi.battery.time", battime)) + (void)fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.time\"\n"); + + if (battime != -1) + snprintf(buf, n, "Discharging, remaining %d:%2.2d", battime / 60, battime % 60); + else + snprintf(buf, n, "Battery is charging"); + } int open_i2c_sensor(const char *dev, const char *type, int n, int *div) @@ -312,9 +326,23 @@ char* get_acpi_ac_adapter(void) { - return "blah"; + int state; + char *acstate = (char*)malloc(100); + + if (GETSYSCTL("hw.acpi.acline", state)) { + (void)fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n"); + return "n\\a"; + } + + if (state) + strcpy(acstate,"Running on AC Power"); + else + strcpy(acstate, "Running on battery"); + + return acstate; } char* get_acpi_fan() { + return ""; } diff -ruN torsmo.orig/files/patch-torsmo.c torsmo/files/patch-torsmo.c --- torsmo.orig/files/patch-torsmo.c Thu Jan 1 03:00:00 1970 +++ torsmo/files/patch-torsmo.c Thu Aug 5 19:40:32 2004 @@ -0,0 +1,11 @@ +--- torsmo.c.orig Thu Aug 5 19:39:06 2004 ++++ torsmo.c Thu Aug 5 19:39:20 2004 +@@ -998,7 +998,7 @@ + } + OBJ(acpitemp) { + /* does anyone have decimals in acpi temperature? */ +- snprintf(p, n, "%d", (int) get_acpi_temperature(obj->data.i)); ++ snprintf(p, n, "%0.1f", (int) get_acpi_temperature(obj->data.i)); + } + OBJ(acpifan) { + snprintf(p, n, "%s", get_acpi_fan()); >Release-Note: >Audit-Trail: >Unformatted: