Skip to contentSkip to conversation

Better battery info/status files

PATCH Pavel Machek 9 participants 17 messages Feb 2, 2001 – Feb 6, 2001 ACPI

lore
Share & tools
lore
#0 lore raw

Hi!

This fixes units, and makes format tag: value. Please apply.
Pavel

drivers/acpi/cmbatt.c +29 -46
@@ -246,38 +254,32 @@
 		goto end;
 	}
 
-	if (info->last_full_capacity == ACPI_BATT_UNKNOWN)
-		p += sprintf(p, "Unknown last full capacity\n");
-	else
-		p += sprintf(p, "Last Full Capacity %x %s /hr\n", 
+	if (info->last_full_capacity != ACPI_BATT_UNKNOWN)
+		p += sprintf(p, "Last Full Capacity: %d %sh\n", 
 		     info->last_full_capacity, batt_list[batt_num].power_unit);
 
-	if (info->design_capacity == ACPI_BATT_UNKNOWN)
-		p += sprintf(p, "Unknown Design Capacity\n");
-	else
-		p += sprintf(p, "Design Capacity %x %s /hr\n", 
+	if (info->design_capacity != ACPI_BATT_UNKNOWN)
+		p += sprintf(p, "Design Capacity:    %d %sh\n", 
 		     info->design_capacity, batt_list[batt_num].power_unit);
 	
 	if (info->battery_technology)
-		p += sprintf(p, "Secondary Battery Technology\n");
+		p += sprintf(p, "Battery Technology: Secondary\n");
 	else
-		p += sprintf(p, "Primary Battery Technology\n");
+		p += sprintf(p, "Battery Technology: Primary\n");
 	
-	if (info->design_voltage == ACPI_BATT_UNKNOWN)
-		p += sprintf(p, "Unknown Design Voltage\n");
-	else
-		p += sprintf(p, "Design Voltage %x mV\n", 
+	if (info->design_voltage != ACPI_BATT_UNKNOWN)
+		p += sprintf(p, "Design Voltage:     %d mV\n", 
 		     info->design_voltage);
 	
-	p += sprintf(p, "Design Capacity Warning %d\n",
-		info->design_capacity_warning);
-	p += sprintf(p, "Design Capacity Low %d\n",
-		info->design_capacity_low);
-	p += sprintf(p, "Battery Capacity Granularity 1 %d\n",
+	p += sprintf(p, "Design Capacity Warning:    %d %sh\n",
+		info->design_capacity_warning, batt_list[batt_num].power_unit);
+	p += sprintf(p, "Design Capacity Low:        %d %sh\n",
+		info->design_capacity_low, batt_list[batt_num].power_unit);
+	p += sprintf(p, "Battery Capacity Granularity 1: %d\n",
 		info->battery_capacity_granularity_1);
-	p += sprintf(p, "Battery Capacity Granularity 2 %d\n",
+	p += sprintf(p, "Battery Capacity Granularity 2: %d\n",
 		info->battery_capacity_granularity_2);
-	p += sprintf(p, "model number %s\nserial number %s\nbattery type %s\nOEM info %s\n",
+	p += sprintf(p, "Model number; %s\nSerial number: %s\nBattery type: %s\nOEM info: %s\n",
 		info->model_number,info->serial_number,
 		info->battery_type,info->oem_info);
 end:
@@ -308,40 +310,29 @@
 		goto end;
 	}
 
-	printk("getting batt status\n");
-
 	if (acpi_get_battery_status(batt_list[batt_num].handle, &status) != AE_OK) {
 		printk(KERN_ERR "Cmbatt: acpi_get_battery_status failed\n");
 		goto end;
 	}
 
-	p += sprintf(p, "Remaining Capacity: %x\n", status.remaining_capacity);
+	p += sprintf(p, "Battery discharging:        %s\n",
+		     (status.state & 0x1)?"yes":"no");
+	p += sprintf(p, "Battery charging:           %s\n",
+		     (status.state & 0x2)?"yes":"no");
+	p += sprintf(p, "Battery critically low:     %s\n",
+		     (status.state & 0x4)?"yes":"no");
+
+	if (status.present_rate != ACPI_BATT_UNKNOWN)
+		p += sprintf(p, "Battery rate:               %d %s\n",
+			status.present_rate, batt_list[batt_num].power_unit);
 
-	if (status.state & 0x1)
-		p += sprintf(p, "Battery discharging\n");
-	if (status.state & 0x2)
-		p += sprintf(p, "Battery charging\n");
-	if (status.state & 0x4)
-		p += sprintf(p, "Battery critically low\n");
-
-	if (status.present_rate == ACPI_BATT_UNKNOWN)
-		p += sprintf(p, "Battery rate unknown\n");
-	else
-		p += sprintf(p, "Battery rate %x\n",
-			status.present_rate);
-
-	if (status.remaining_capacity == ACPI_BATT_UNKNOWN)
-		p += sprintf(p, "Battery capacity unknown\n");
-	else
-		p += sprintf(p, "Battery capacity %x %s\n",
+	if (status.remaining_capacity != ACPI_BATT_UNKNOWN)
+		p += sprintf(p, "Battery capacity:           %d %sh\n",
 			status.remaining_capacity, batt_list[batt_num].power_unit);
 
-	if (status.present_voltage == ACPI_BATT_UNKNOWN)
-		p += sprintf(p, "Battery voltage unknown\n");
-	else
-		p += sprintf(p, "Battery voltage %x volts\n",
+	if (status.present_voltage != ACPI_BATT_UNKNOWN)
+		p += sprintf(p, "Battery voltage:            %d mV\n",
 			status.present_voltage);
-
 end:
 
 	len = (p - page);
Signature · 6 lines
I'm [email protected]. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at [email protected]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#1 lore raw
Quoted 1 line

This fixes units, and makes format tag: value. Please apply.

The units seem to vary. I suggest using fundamental SI units. That would be meters, kilograms, seconds, and maybe a very few others -- my memory fails me on this.

Power meter applets will be eternally buggy if you force them to deal with units that change. In fact there is no reason to print the units if you always use the fundamental units.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
Quoted 3 lines · Albert D. Cahalan

The units seem to vary. I suggest using fundamental SI units. That would be meters, kilograms, seconds, and maybe a very few others -- my memory fails me on this.

iirc, SI comes from France, and therefore it should be "metres"

[flames to /dev/null please] ;)

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
Quoted 6 lines · Russell King
Quoted 3 lines · Albert D. Cahalan

The units seem to vary. I suggest using fundamental SI units. That would be meters, kilograms, seconds, and maybe a very few others -- my memory fails me on this.

iirc, SI comes from France, and therefore it should be "metres"

Yes. Quite why a distance matters to the battery is another question, though...

For the end-user, the ability to see readings in other units would be useful - how many people on this list work in litres/metres/kilometres, and how many in gallons/feet/miles? Probably enough in both groups that neither could count as universal...

James.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw
Quoted 4 lines · James Sutherland
Quoted 1 line · Russell King

Albert D. Cahalan writes:

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

The units seem to vary. I suggest using fundamental SI units. That would be meters, kilograms, seconds, and maybe a very few others -- my memory fails me on this.

iirc, SI comes from France, and therefore it should be "metres"

Yes. Quite why a distance matters to the battery is another question, though...

Quite. We all know its only the kilograms that matter in a notebook!

Regards,
Steve
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#5 lore raw
In reply to James Sutherland
Quoted 4 lines · James Sutherland

For the end-user, the ability to see readings in other units would be useful - how many people on this list work in litres/metres/kilometres, and how many in gallons/feet/miles? Probably enough in both groups that neither could count as universal...

Yeah. We can have this as part of the locale settings, changable by echoing the desired locale string to /proc/sys/kernel/lc_all.

Signature · 7 lines
dwmw2


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#6 lore raw
Quoted 11 lines · David Woodhouse
Quoted 4 lines · James Sutherland

For the end-user, the ability to see readings in other units would be useful - how many people on this list work in litres/metres/kilometres, and how many in gallons/feet/miles? Probably enough in both groups that neither could count as universal...

Yeah. We can have this as part of the locale settings, changable by echoing the desired locale string to /proc/sys/kernel/lc_all.

-

Just an idea, . . but isn't this something better done in userland?

(ben@Deacon)-(06:49am Sun Feb 4)-(ben)

$ date  +%s
981298161
(ben@Deacon)-(06:49am Sun Feb  4)-(ben)
$ date  +%c
Sun Feb  4 06:49:24 2001

-b

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#7 lore raw
Quoted 14 lines · Ben Ford
Quoted 11 lines · David Woodhouse
Quoted 4 lines · James Sutherland

For the end-user, the ability to see readings in other units would be useful - how many people on this list work in litres/metres/kilometres, and how many in gallons/feet/miles? Probably enough in both groups that neither could count as universal...

Yeah. We can have this as part of the locale settings, changable by echoing the desired locale string to /proc/sys/kernel/lc_all.

-

Quoted 8 lines

Just an idea, . . but isn't this something better done in userland?

(ben@Deacon)-(06:49am Sun Feb 4)-(ben)

$ date  +%s
981298161
(ben@Deacon)-(06:49am Sun Feb  4)-(ben)
$ date  +%c
Sun Feb  4 06:49:24 2001

That's what I'd do, anyway - /dev/pieceofstring would return the length of said piece of string in some units, explicityly stated. (e.g. "5m" or "15ft").

"uname -s" ("how long's a piece of string on this system") would then convert the length into feet, metres or fathoms, depending on what the user prefers.

James.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#8 lore raw
Quoted 30 lines · James Sutherland
Quoted 14 lines · Ben Ford
Quoted 11 lines · David Woodhouse
Quoted 4 lines · James Sutherland

For the end-user, the ability to see readings in other units would be useful - how many people on this list work in litres/metres/kilometres, and how many in gallons/feet/miles? Probably enough in both groups that neither could count as universal...

Yeah. We can have this as part of the locale settings, changable by echoing the desired locale string to /proc/sys/kernel/lc_all.

-

Quoted 8 lines

Just an idea, . . but isn't this something better done in userland?

(ben@Deacon)-(06:49am Sun Feb 4)-(ben)

$ date  +%s
981298161
(ben@Deacon)-(06:49am Sun Feb  4)-(ben)
$ date  +%c
Sun Feb  4 06:49:24 2001

That's what I'd do, anyway - /dev/pieceofstring would return the length of said piece of string in some units, explicityly stated. (e.g. "5m" or "15ft").

Quoted 5 lines

"uname -s" ("how long's a piece of string on this system") would then convert the length into feet, metres or fathoms, depending on what the user prefers.

James.

Don't get carried away. In the present context we are only talking about time and electrical measurements. Whilst most of the human race can't read the English labels in /proc, they all use the same measurements for electrical units and time (unless the time exceeds 24 hours, where dates get a bit screwed up). In this case even the US in in line with the rest of humanity............. or would you like to be able to express battery capacity in BTUs?

Regards,
Steve
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#9 lore raw
Quoted 30 lines · Steve Underwood
Quoted 21 lines · James Sutherland
Quoted 11 lines · Ben Ford
Quoted 9 lines · David Woodhouse
Quoted 4 lines · James Sutherland

For the end-user, the ability to see readings in other units would be useful - how many people on this list work in litres/metres/kilometres, and how many in gallons/feet/miles? Probably enough in both groups that neither could count as universal...

Yeah. We can have this as part of the locale settings, changable by echoing the desired locale string to /proc/sys/kernel/lc_all.

Quoted 8 lines

Just an idea, . . but isn't this something better done in userland?

(ben@Deacon)-(06:49am Sun Feb 4)-(ben)

$ date  +%s
981298161
(ben@Deacon)-(06:49am Sun Feb  4)-(ben)
$ date  +%c
Sun Feb  4 06:49:24 2001
Quoted 7 lines

That's what I'd do, anyway - /dev/pieceofstring would return the length of said piece of string in some units, explicityly stated. (e.g. "5m" or "15ft").

"uname -s" ("how long's a piece of string on this system") would then convert the length into feet, metres or fathoms, depending on what the user prefers.

Quoted 7 lines

Don't get carried away. In the present context we are only talking about time and electrical measurements. Whilst most of the human race can't read the English labels in /proc, they all use the same measurements for electrical units and time (unless the time exceeds 24 hours, where dates get a bit screwed up). In this case even the US in in line with the rest of humanity............. or would you like to be able to express battery capacity in BTUs?

Personally, I'd prefer a percentage and/or estimated time remaining anyway... However, from the kernel's PoV, the rule is just "KISS". Print in something consistent, let userspace do any conversions you want. Probably seconds for time (simplest - scripts can compare "if est_batterylife_remaining < 300 do something", UI things can convert to H:M:S or whatever), watts for power.

What is measured, BTW - battery voltage, presumably, and drain current?

James.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#10 lore raw
In reply to James Sutherland
Quoted 8 lines · James Sutherland
Quoted 5 lines · Ben Ford
Quoted 2 lines · David Woodhouse

Yeah. We can have this as part of the locale settings, changeable by echoing the desired locale string to /proc/sys/kernel/lc_all.

Just an idea, . . but isn't this something better done in userland?

That's what I'd do, anyway

STOP!

I'll repeat myself, in the en_US locale this time...

<SARCASM>
Yeah. We can have this as part of the locale settings, changeable by echoing the desired locale string to /proc/sys/kernel/lc_all. </SARCASM>
<SUBTEXT TYPE=HIDDEN>Go away and troll elsewhere</SUBTEXT>

Signature · 8 lines
dwmw2



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#11 lore raw
Quoted 24 lines · David Woodhouse
Quoted 2 lines · James Sutherland
Quoted 1 line · Ben Ford

David Woodhouse wrote:

Quoted 7 lines · James Sutherland

For the end-user, the ability to see readings in other units would be useful - how many people on this list work in litres/metres/kilometres, and how many in gallons/feet/miles? Probably enough in both groups that neither could count as universal...

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Yeah. We can have this as part of the locale settings, changeable by echoing the desired locale string to /proc/sys/kernel/lc_all.

Just an idea, . . but isn't this something better done in userland?

That's what I'd do, anyway

STOP!

I'll repeat myself, in the en_US locale this time...

Quoted 8 lines

<SARCASM>
Yeah. We can have this as part of the locale settings, changeable by echoing the desired locale string to /proc/sys/kernel/lc_all. </SARCASM>
<SUBTEXT TYPE=HIDDEN>Go away and troll elsewhere</SUBTEXT>

--
dwmw2

You have an odd definition of troll. Tell me, who is trolling, the guy who posts something trying to help or the guy who posts sarcastic responses to things? You appear to have a major case of little-dick syndrome.

-b

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#12 lore raw
In reply to Ben Ford
Quoted 4 lines
Quoted 2 lines

Yeah. We can have this as part of the locale settings, changable by echoing the desired locale string to /proc/sys/kernel/lc_all.

Just an idea, . . but isn't this something better done in userland?

Please remember this is an international list. For the benefit of certain users please mark all sarcasm with the word NOT or a simply face

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#13 lore raw
In reply to Albert D. Cahalan
Quoted 3 lines

The units seem to vary. I suggest using fundamental SI units. That would be meters, kilograms, seconds, and maybe a very few others -- my memory fails me on this.

There are lots of SI units, one for each physical dimension that can be measured. Some of the ones that might apply here are:

- Volts
- Coulombs
- Watts
- Amperes
- Seconds
- Joules

Some non-SI units that may be acceptable in this context due to common usage:

- Watt-hours (should strictly be joules for this measurement)

--------------------------------------------------------------

from:     Jonathan "Chromatix" Morton
mail:     [email protected]  (not for attachments)
big-mail: [email protected]
uni-mail: [email protected]

The key to knowledge is not to rely on people to teach you it.

Get VNC Server for Macintosh from http://www.chromatix.uklinux.net/vnc/

-----BEGIN GEEK CODE BLOCK-----
Version 3.12
GCS$/E/S dpu(!) s:- a20 C+++ UL++ P L+++ E W+ N- o? K? w--- O-- M++$ V? PS PE- Y+ PGP++ t- 5- X- R !tv b++ DI+++ D G e+ h+ r- y+
-----END GEEK CODE BLOCK-----

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#14 lore raw
Quoted 7 lines
Quoted 3 lines

The units seem to vary. I suggest using fundamental SI units. That would be meters, kilograms, seconds, and maybe a very few others -- my memory fails me on this.

There are lots of SI units, one for each physical dimension that can be measured. Some of the ones that might apply here are:

Quoted 6 lines

- Volts
- Coulombs
- Watts
- Amperes
- Seconds
- Joules

No, these are not all fundamental.

1 Joule == 1 newton * 1 meter

The newton isn't fundamental either. It is defined in terms of meters, seconds, and kilograms.

So if I've not mucked something up, 1 J == 1 m*kg*m/s/s.

Units get ugly when arbitrary powers of 10 get thrown in, and worse with random odd constants. Amperes have a 2.0e-7 in the definition.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#15 lore raw
In reply to Pavel Machek

Hi!

Quoted 5 lines
Quoted 1 line

This fixes units, and makes format tag: value. Please apply.

The units seem to vary. I suggest using fundamental SI units. That would be meters, kilograms, seconds, and maybe a very few others -- my memory fails me on this.

No!

volt = m^2 g sec^-3 A^-1

I do not want to learn that my battery has voltage of

10.8 m^2 g sec^-3 A^-1

!

Pavel

Signature · 6 lines
I'm [email protected]. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at [email protected]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#16 lore raw
In reply to Pavel Machek

Hi!

Quoted 9 lines
Quoted 1 line

This fixes units, and makes format tag: value. Please apply.

The units seem to vary. I suggest using fundamental SI units. That would be meters, kilograms, seconds, and maybe a very few others -- my memory fails me on this.

Power meter applets will be eternally buggy if you force them to deal with units that change. In fact there is no reason to print the units if you always use the fundamental units.

Problem is that _hardware_ wants to talk us two different units.

Sometimes it wants to tell us watts.

Sometimes hw wants to tell us volts and ampers.

I believe kernel should not do any translation. [It is _not_ trivial -- if battery voltage changes with time.]
Pavel

Signature · 6 lines
I'm [email protected]. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at [email protected]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/