On 11 October 2014 07:24, Isaac Dunham <[email protected]> wrote:
> On several occasions I've wished for a tool that can show battery charge,
> whether the power supply is working, and similar things.
> Some time back I wrote the original version of this for toybox;
> I just ported it to BusyBox.
>
> If anyone could review it, I'd appreciate that.
Thanks for porting this across, I also hope it gets merged (but it's
neater than mine, so I'll use it anyway!)
There is one bug (technically it's a bug in my battery firmware...)
but easy to fix. Here's the output from "real" acpi, your busybox
acpi, and cat:
$ acpi -V
Battery 0: Full, 100%
Battery 0: design capacity 6000 mAh, last full capacity 5900 mAh = 98%
Adapter 0: on-line
Cooling 0: x86_pkg_temp no state information available
Cooling 1: intel_powerclamp no state information available
Cooling 2: Processor 0 of 3
Cooling 3: Processor 0 of 3
Cooling 4: Processor 0 of 3
Cooling 5: Processor 0 of 3
$ ./busybox acpi -V
Adapter 0: on-line
Battery 0: 101%
Thermal 0: 47.0 degrees C
Thermal 1: 37.0 degrees C
Thermal 2: 46.0 degrees C
Thermal 3: 45.0 degrees C
Thermal 4: 44.0 degrees C
Thermal 5: 46.0 degrees C
Thermal 6: 46.0 degrees C
Cooling 0: Processor 0 of 3
Cooling 1: Processor 0 of 3
Cooling 2: Processor 0 of 3
Cooling 3: Processor 0 of 3
Cooling 4: intel_powerclamp -1 of 50
Cooling 5: x86_pkg_temp no state information
$ for X in /sys/class/power_supply/BAT0/c*; do echo "$X: $(<$X)"; done
/sys/class/power_supply/BAT0/capacity: 101
/sys/class/power_supply/BAT0/capacity_level: Full
/sys/class/power_supply/BAT0/charge_full: 5900000
/sys/class/power_supply/BAT0/charge_full_design: 6000000
/sys/class/power_supply/BAT0/charge_now: 6000000
/sys/class/power_supply/BAT0/current_now: 1000
As you can see, 101% is a bad output (but correct reading). I would
change the following:
--- a/miscutils/acpi.c
+++ b/miscutils/acpi.c
@@ -113,7 +113,8 @@
cap = 100 * cur / max;
}
if (cap >= 0)
- printf("Battery %d: %d%%\n", G.bat++, cap);
+ printf("Battery %d: %d%%\n", G.bat++,
+ (cap > 100 ? 100 : cap));
} else if ((opts & FLAG_a)
&& ((on = read_int_at(dfd, "online")) >= 0)) {
And as an incredibly minor trivial thing; your patch file has 1 extra
newline at the end (which makes patch complain).
Thanks,
Steven
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox