Re: -current sensorsd doesn't work for me

2007-01-13 Thread andrew fresh
I am CC'ing tech@ not because I like to crosspost, but because I believe
this to be the end of a conversation on misc@ and the start of a
discussion on tech@ about hopefully getting this changed.

On Sat, Jan 13, 2007 at 10:11:24AM -0500, Constantine A. Murenin wrote:
> On 12/01/07, andrew fresh <[EMAIL PROTECTED]> wrote:
> >I am trying to shut down my laptop using the voltage sensors.
> >Unfortunatly I can't test this with a generic kernel because all my
> >sensors on my only -current box come from the ACPI subsystem.
> >
> >The problem is, the limits don't seems to work:
> >
> >$ sysctl hw.sensors.acpibat0.volt1
> >hw.sensors.acpibat0.volt1=7.96 VDC (current voltage), OK
> >$ tail -3 /etc/sensorsd.conf
> >hw.sensors.acpibat0.volt1:low=8V:high=9V

no matter what I set, sensorsd always says "within limits".

> sensorsd.conf(5) says [that's how it is supposed to work]
> 
> The following patch will allow you to set high and low values for
> volt0 and volt1 on acpibat in sensorsd:

I think would prefer this patch, or something like it, just in case I
want to override the choices someone made for other sensors.

I believe this diff adds useful functionality without losing anything.
However, I am NOT a C programmer, so I may have screwed something up.

Index: sensorsd.c
===
RCS file: /cvs/src/usr.sbin/sensorsd/sensorsd.c,v
retrieving revision 1.27
diff -u -r1.27 sensorsd.c
--- sensorsd.c  6 Jan 2007 18:17:06 -   1.27
+++ sensorsd.c  13 Jan 2007 18:15:12 -
@@ -218,7 +218,9 @@
 * status had failed so warn about it */
if (newstatus == SENSOR_S_UNKNOWN)
newstatus = SENSOR_S_WARN;
-   else if (newstatus == SENSOR_S_UNSPEC) {
+   else if (newstatus == SENSOR_S_UNSPEC ||
+   limit->upper != LLONG_MAX  ||
+   limit->lower != LLONG_MIN) {
if (sensor.value > limit->upper ||
sensor.value < limit->lower)
newstatus = SENSOR_S_CRIT;
Index: sensorsd.conf.5
===
RCS file: /cvs/src/usr.sbin/sensorsd/sensorsd.conf.5,v
retrieving revision 1.10
diff -u -r1.10 sensorsd.conf.5
--- sensorsd.conf.5 28 Dec 2006 10:04:27 -  1.10
+++ sensorsd.conf.5 13 Jan 2007 18:15:12 -
@@ -58,8 +58,8 @@
 .Xr esm 4 ,
 or
 .Xr ipmi 4 )
-do not require boundary values specified (that otherwise will be
-ignored) and simply trigger on status transitions.
+do not require boundary values specified and simply trigger on status
+transitions unless you specify either boundry.
 .Pp
 The command is executed on transitions out of, and back into, given limits.
 Tokens in the command are substituted as follows:
===

l8rZ,
-- 
andrew - ICQ# 253198 - JID: [EMAIL PROTECTED]

BOFH excuse of the day: (l)user error



Re: -current sensorsd doesn't work for me

2007-01-13 Thread Constantine A. Murenin

On 12/01/07, andrew fresh <[EMAIL PROTECTED]> wrote:

I am trying to shut down my laptop using the voltage sensors.
Unfortunatly I can't test this with a generic kernel because all my
sensors on my only -current box come from the ACPI subsystem.

The problem is, the limits don't seems to work:

$ sysctl hw.sensors.acpibat0.volt1
hw.sensors.acpibat0.volt1=7.96 VDC (current voltage), OK
$ tail -3 /etc/sensorsd.conf
hw.sensors.acpibat0.volt1:low=8V:high=9V


sensorsd.conf(5) says the following:

Sensors that provide status (such as from bio(4), esm(4), or ipmi(4)) do
not require boundary values specified (that otherwise will be ignored)
and simply trigger on status transitions.


However, volt0 and volt1 on acpibat never change status from an "OK",
so they will never be triggered in sensorsd, which may or may not be
desirable behaviour.

The following patch will allow you to set high and low values for
volt0 and volt1 on acpibat in sensorsd:

Index: dev/acpi/acpibat.c
===
RCS file: /cvs/src/sys/dev/acpi/acpibat.c,v
retrieving revision 1.37
diff -u -d -p -8 -r1.37 acpibat.c
--- dev/acpi/acpibat.c  2006/12/26 23:58:08 1.37
+++ dev/acpi/acpibat.c  2006/12/31 18:53:01
@@ -128,17 +128,16 @@ acpibat_monitor(struct acpibat_softc *sc
sizeof(sc->sc_sens[2].desc));
sc->sc_sens[2].type = type;
sensor_attach(&sc->sc_sensdev, &sc->sc_sens[2]);
sc->sc_sens[2].value = sc->sc_bif.bif_low * 1000;

strlcpy(sc->sc_sens[3].desc, "voltage", sizeof(sc->sc_sens[3].desc));
sc->sc_sens[3].type = SENSOR_VOLTS_DC;
sensor_attach(&sc->sc_sensdev, &sc->sc_sens[3]);
-   sc->sc_sens[3].status = SENSOR_S_OK;
sc->sc_sens[3].value = sc->sc_bif.bif_voltage * 1000;

strlcpy(sc->sc_sens[4].desc, "battery unknown",
sizeof(sc->sc_sens[4].desc));
sc->sc_sens[4].type = SENSOR_INTEGER;
sensor_attach(&sc->sc_sensdev, &sc->sc_sens[4]);
sc->sc_sens[4].status = SENSOR_S_UNKNOWN;
sc->sc_sens[4].value = sc->sc_bst.bst_state;
@@ -153,17 +152,16 @@ acpibat_monitor(struct acpibat_softc *sc
sc->sc_sens[6].type = type;
sensor_attach(&sc->sc_sensdev, &sc->sc_sens[6]);
sc->sc_sens[6].value = sc->sc_bst.bst_capacity * 1000;

strlcpy(sc->sc_sens[7].desc, "current voltage",
sizeof(sc->sc_sens[7].desc));
sc->sc_sens[7].type = SENSOR_VOLTS_DC;
sensor_attach(&sc->sc_sensdev, &sc->sc_sens[7]);
-   sc->sc_sens[7].status = SENSOR_S_OK;
sc->sc_sens[7].value = sc->sc_bst.bst_voltage * 1000;

sensordev_install(&sc->sc_sensdev);
}

void
acpibat_refresh(void *arg)
{



-current sensorsd doesn't work for me

2007-01-12 Thread andrew fresh
I am trying to shut down my laptop using the voltage sensors.
Unfortunatly I can't test this with a generic kernel because all my
sensors on my only -current box come from the ACPI subsystem.

The problem is, the limits don't seems to work:

$ sysctl hw.sensors.acpibat0.volt1
hw.sensors.acpibat0.volt1=7.96 VDC (current voltage), OK
$ tail -3 /etc/sensorsd.conf
hw.sensors.acpibat0.volt1:low=8V:high=9V
#:command=/etc/sensorsd/shutdown "%2" "%3"

$ sudo sensorsd -d
^C
$ tail -1 /var/log/messages
Jan 12 18:25:24 trin sensorsd[15369]: hw.sensors.acpibat0.volt1: within limits, 
value: 7.96 V DC
$

I think that should trip the low limit.

I changed it to "low=5V:high=9V" and it works as expected.  The log says
it is within limits.

But, if I change the entry in sensorsd.conf to "low=5V:high=6V" (should
trip the high limit) it still claims the sensors are within limits.

Am I doing something stupid?


The diff for the acpi kernel

--- GENERIC Fri Jan  5 18:54:24 2007
+++ ACPIThu Jan 11 21:20:37 2007
@@ -57,19 +57,19 @@
 eisa0  at mainbus0
 pci*   at mainbus0
 
-#optionACPIVERBOSE
-#optionACPI_ENABLE
+option ACPIVERBOSE
+option ACPI_ENABLE
 
-acpi0  at mainbus? disable
-#acpitimer*at acpi?
-#acpihpet* at acpi?
-#acpiac*   at acpi?
-#acpibat*  at acpi?
-#acpibtn*  at acpi?
-#acpicpu*  at acpi?
-acpiec*at acpi?disable
+acpi0  at mainbus?
+acpitimer* at acpi?
+acpihpet*  at acpi?
+acpiac*at acpi?
+acpibat*   at acpi?
+acpibtn*   at acpi?
+acpicpu*   at acpi?
+acpiec*at acpi?
 acpiprt*   at acpi?
-#acpitz*   at acpi?
+acpitz*at acpi?
 
 option PCIVERBOSE
 option EISAVERBOSE

and my DMESG

OpenBSD 4.0-current (ACPI) #1: Thu Jan 11 21:42:30 MST 2007
[EMAIL PROTECTED]:/usr/src/sys/arch/i386/compile/ACPI
cpu0: Intel(R) Pentium(R) M processor 1.30GHz ("GenuineIntel" 686-class) 1.30 
GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2
real mem  = 1063415808 (1038492K)
avail mem = 961875968 (939332K)
using 4256 buffers containing 53293056 bytes (52044K) of memory
mainbus0 (root)
bios0 at mainbus0: AT/286+(d8) BIOS, date 12/01/05, BIOS32 rev. 0 @ 0xfd6a0, 
SMBIOS rev. 2.3 @ 0xd8010 (17 entries)
bios0: Sony Corporation VGN-TX770P
apm0 at bios0: Power Management spec V1.2
apm0: AC on, battery charge unknown
apm0: flags 30102 dobusy 0 doidle 1
pcibios0 at bios0: rev 2.1 @ 0xfd6a0/0x960
pcibios0: PCI BIOS has 17 Interrupt Routing table entries
pcibios0: PCI Interrupt Router at 000:31:0 ("Intel 82801FBM LPC" rev 0x00)
pcibios0: PCI bus #7 is the last bus
bios0: ROM list: 0xc/0x1! 0xd8000/0x4000! 0xdc000/0x4000!
acpi0 at mainbus0: rev 0
acpi0: tables DSDT FACP APIC BOOT MCFG SSDT SSDT SSDT SSDT 
acpitimer0 at acpi0: can't identify bus
acpi device at acpi0 from table DSDT not configured
acpi device at acpi0 from table FACP not configured
acpi device at acpi0 from table APIC not configured
acpi device at acpi0 from table BOOT not configured
acpi device at acpi0 from table MCFG not configured
acpi device at acpi0 from table SSDT not configured
acpi device at acpi0 from table SSDT not configured
acpi device at acpi0 from table SSDT not configured
acpi device at acpi0 from table SSDT not configured
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 0 (PEGP)
acpiprt2 at acpi0: bus 6 (PCIB)
acpiec0 at acpi0: EC0_
acpibtn0 at acpi0: LID0
acpibtn1 at acpi0: PWRB
acpibat0 at acpi0: BAT1: model:  serial:  type: LION oem: Sony Corp.
acpiac0 at acpi0: AC unit online
acpicpu0 at acpi0: CPU0: 1300, 1000, 800, 600 MHz
acpitz0 at acpi0, critical temperature: 99 degC
cpu0 at mainbus0
pci0 at mainbus0 bus 0: configuration mode 1 (no bios)
pchb0 at pci0 dev 0 function 0 "Intel 82915GM/PM/GMS Host" rev 0x03
vga1 at pci0 dev 2 function 0 "Intel 82915GM/GMS Video" rev 0x03: aperture at 
0xb008, size 0x1000
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
"Intel 82915GM/GMS Video" rev 0x03 at pci0 dev 2 function 1 not configured
azalia0 at pci0 dev 27 function 0 "Intel 82801FB HD Audio" rev 0x03: irq 10
azalia0: host: High Definition Audio rev. 1.0
azalia0: codec: Realtek ALC260 (rev. 3.0), HDA version 1.0
azalia0: codec: 0x04x/0x14f1 (rev. 0.0), HDA version 0.9
azalia0: codec[1]: No support for modem function groups
azalia0: codec[1]: No audio function groups
audio0 at azalia0
uhci0 at pci0 dev 29 function 0 "Intel 82801FB USB" rev 0x03: irq 10
usb0 at uhci0: USB revision 1.0
uhub0 at usb0
uhub0: Intel UHCI root hub, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
uhci1 at pci0 dev 29 function 1 "Intel 82801FB USB" rev 0x03: irq 10
usb1 at uhci1: USB revision 1.0
uhub1 at usb1
uhub1: Intel UHCI root hub, rev 1.00/1.00, addr 1
uhub1: 2 ports with 2 removable,