Skip to contentSkip to conversation

Warn user when battery goes critical

PATCH Pavel Machek 5 participants 5 messages Apr 5, 2004 – Apr 13, 2004 3 messages not in the archive ACPI

lore
Share & tools
lore
#0 lore raw

Hi!

When battery is going critical, perhaps user should know? It already helped me when power was turned off at expansion cord...

Pavel

drivers/acpi/battery.c +7 -0
Index: linux/drivers/acpi/battery.c
===================================================================
@@ -332,6 +332,13 @@
 
 	battery->flags.present = device->status.battery_present;
 
+	{
+		struct acpi_battery_status *bst = NULL;
+		int res = acpi_battery_get_status(battery, &bst);
+
+		if (!res && (bst->state & 0x04))
+			printk(KERN_CRIT "Battery status: critical\n");
+	}
 	return_VALUE(result);
 }
 
Signature · 9 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

A message that is not in the archive (sent off-list or not yet received): 20040405211032.GA3575-I/[email protected]

#2 lore raw

drivers/acpi/battery.c line 337

Quoted 4 lines · Pavel Machek

When battery is going critical, perhaps user should know? It already helped me when power was turned off at expansion cord...

drivers/acpi/battery.c +1 -0
+		int res = acpi_battery_get_status(battery, &bst);

If this patch goes in, PLEASE, create a way to turn that feature OFF or to control the interval at which it is run, since on some laptops (this one) the battery status BIOS call takes too long, interrupts are disabled then, and touch-pad and keyboard interrupts are lost, causing pointer warps, bouncy or "stickyyyyyyyyyyyy" keys, and keyboard lockouts. It is also probably the cause of a system hang during heavy network I/O.

Signature · 11 lines
If you feel like the machines are conspiring against you,
then it's time to perspire against the machines.




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
#3 lore raw
In reply to a message not in the archive

drivers/acpi/battery.c line 340

Quoted 7 lines · Pavel Machek

Hi!

When battery is going critical, perhaps user should know? It already helped me when power was turned off at expansion cord...

drivers/acpi/battery.c +2 -0
+		if (!res && (bst->state & 0x04))
+			printk(KERN_CRIT "Battery status: critical\n");

This should go into userspace IMO. There are some applications that will handle this, so no need for code bloat in the kernel.

Hey! I'd never thought i could one day accuse Pavel of "eyecandy bloat" ;-)

Happy Easter,

Stefan

Signature · 9 lines
Stefan Seyfried



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

A message that is not in the archive (sent off-list or not yet received): 20040408171527.GH23710-l0tNAEGuAhhzZ8+rp42Dbp9+tswZ0GTaehPwdyo5hKaELgA04lAiVw@public.gmane.org

#5 lore raw

Hi,
I am think in reply to this question a long time, well because I not a man of the code, it is goes my reflection, I turn acpi debug on because I want to know in /var/log em battery got one "bat low 2" but is very annoying applet monitor every time that ask battery stat appears :
[ACPI Debug] String: Length 0x24, "---------------------------- AC _PSR" [ACPI Debug] String: Length 0x27, "---------------------------- AC on line"
[ACPI Debug] String: Length 0x30, "--------- VIA SOFTWARE SMI PMIO 2Fh
------
this messages are written in DSDT, so is just select the more imports
and the DEBUG messages from DSDT.

Bye

Quoted 18 lines · Stefan Seyfried

drivers/acpi/battery.c line 340

Quoted 7 lines · Pavel Machek

Hi!

When battery is going critical, perhaps user should know? It already helped me when power was turned off at expansion cord...

drivers/acpi/battery.c +2 -0
+		if (!res && (bst->state & 0x04))
+			printk(KERN_CRIT "Battery status: critical\n");

This should go into userspace IMO. There are some applications that will handle this, so no need for code bloat in the kernel.

Hey! I'd never thought i could one day accuse Pavel of "eyecandy bloat" ;-)

Happy Easter,

Stefan

Signature · 9 lines
Sérgio M. B.



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click

A message that is not in the archive (sent off-list or not yet received): 1081802715.3428.40.camel-4/[email protected]

#7 lore raw

Hi!

Quoted 11 lines
Quoted 11 lines

drivers/acpi/battery.c line 340

Quoted 5 lines

When battery is going critical, perhaps user should know? It already helped me when power was turned off at expansion cord...

drivers/acpi/battery.c +2 -0
+		if (!res && (bst->state & 0x04))
+			printk(KERN_CRIT "Battery status: critical\n");

This should go into userspace IMO. There are some applications that will handle this, so no need for code bloat in the kernel.

Hey! I'd never thought i could one day accuse Pavel of "eyecandy bloat" ;-)

:-). Yes battery monitors exist and yes, I should watch /proc/acpi/battery.../state; otoh it is clearly an critical condition, and I should not be forced to run cpu-eating battery monitor daemon when kernel knows without polling.

Pavel

Signature · 9 lines
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click