WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: flit - battery monitor ineffective, fix  (Read 3890 times)

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
flit - battery monitor ineffective, fix
« on: September 27, 2009, 10:35:16 AM »
I run an HP Mini 1001. Flit wouldn't display my battery state/level. I did some debugging, and flit seems to find all the right numbers from the state & info files. It never does the calculation, though.

For me, a change to flit.cpp (code v0.9.4) fixes it. Diff:

Code: [Select]
681c681
<                 if (!need_rate && !need_charge && !need_state) {
---
>                 if (need_rate || need_charge || need_state) {

Does anybody else have this problem, or is it just me?

Great program, Michael - simple, quick, effective. Hope this helps, in any case!

Offline MikeLockmoore

  • Hero Member
  • *****
  • Posts: 525
  • Good software needn't be big!
Re: flit - battery monitor ineffective, fix
« Reply #1 on: September 27, 2009, 11:30:15 AM »
I'm glad you like Flit.  But I'm surprised your change actually fixes it for you!  Those 'need_xxx' variables indicate whether Flit still needs to collect some information before doing the calculation... so your change effectively says, "if I still need to collect the charge rate info, OR I need to collect the charge level info, OR I still need to collect the battery state info, just go ahead with the calculations anyway..."

The current version posted in 0.9.8.  I'm planning to relase 1.0.0 soon, but if you have a real bug, I might be able to fix it before that.  However, since you are capable of changing the code anyway, could you please try an unmodified copy of version 0.9.8 on your system?  It is posted here: http://forum.tinycorelinux.net/index.php?topic=2818.0

If 0.9.8 is not working for you either, maybe compile with the DIAG option and launch it from a terminal window to see the diagnostics printf( ) output text and let us know what you see. Post the first 50 lines or so of DIAG-enabled text output of Flit and maybe a copy of your /proc/acpi/battery/BAT*/info 'file' and a copy of /proc/acpi/battery/BAT*/status during the three important states: charging, discharging, and fully charged.
--
Mike L.
     

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: flit - battery monitor ineffective, fix
« Reply #2 on: September 27, 2009, 07:15:53 PM »
Ah! -There- is the flit conversation! I'll read through that thread and catch up, too.

I'll get through this later today, and will attach the DIAG, state, and info details here as requested.

EDIT: Plain-jane 0.9.8 compile has the same problem - it shows an AC cable, and a blue battery with red outline. I've attached state/info output on charging, discharging. I'll follow up with charged details, but have to wait on the battery and all. I also enabled DIAG and sent the output to log.txt (below). Unfortunately, there is hardly anything there, even after waiting a min or two. I'll browse the code some more and try to figure out why it's not getting to the printf() calls.

Finally, I am not using the original Makefile (sorry - I couldn't get it to work for me!). I am compiling using fltk-config --compile. TC 2.3.1 flit has this problem out of the box, so I don't think it's b/c the Makefile, but I'll try to straighten that out ASAP for consistency. ... and I'll get the most recent RC to try!

Code: [Select]
CHARGING - STATE
present:                 yes
capacity state:          ok
charging state:          charging
present rate:            unknown
remaining capacity:      1577 mAh
present voltage:         11970 mV

CHARGING - INFO
present:                 yes
design capacity:         2400 mAh
last full capacity:      2229 mAh
battery technology:      rechargeable
design voltage:          11100 mV
design capacity warning: 0 mAh
design capacity low:     0 mAh
capacity granularity 1:  0 mAh
capacity granularity 2:  100 mAh
model number:            Primary
serial number:           
battery type:            LION
OEM info:                Hewlett-Packard

Code: [Select]
DISCHARGING - STATE
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            unknown
remaining capacity:      1581 mAh
present voltage:         11974 mV

DISCHARGING - INFO
present:                 yes
design capacity:         2400 mAh
last full capacity:      2229 mAh
battery technology:      rechargeable
design voltage:          11100 mV
design capacity warning: 0 mAh
design capacity low:     0 mAh
capacity granularity 1:  0 mAh
capacity granularity 2:  100 mAh
model number:            Primary
serial number:           
battery type:            LION
OEM info:                Hewlett-Packard

Code: [Select]
FLIT DIAG OUTPUT

show_clock is 1
show_sound is 0
show_battery is 1
show24hr is 1
oss_control_name is autosel
style is 2
Location spec is nw
Battery capacity is 2229.0 mAh
Root RGB colors are 2B:27:29
« Last Edit: September 27, 2009, 07:38:07 PM by dentonlt »

Offline MikeLockmoore

  • Hero Member
  • *****
  • Posts: 525
  • Good software needn't be big!
Re: flit - battery monitor ineffective, fix
« Reply #3 on: September 27, 2009, 11:56:45 PM »
dentonlt:

Thanks for providing good bug feedback.  I think I'm able to pinpoint the problem now and fix it so it will work for you and generally be more robust for people.  :)

I see that your battery is reporting "unknown" (a text string) as the rate.  That does not allow the version 0.9.8 and earlier code to parse the rate as a number, so the 'need_rate' var is never set to 1, which prevents the later calculations from running.  Which is a shame, since Flit as of version 0.9.4 is able to estimate the charging/discharging rate by looking at the rate of change of the remaining charge, so the rate as reported by acpi is not really neccessary any more.  :-[  But it will be used if provided (it may be more accurate than the simple derivative in Flit).

I also noticed a testing statement that forced the acpi-reported rate to zero in the version 0.9.8 code, which was not meant to be in the released code.   :-[

Anyway, I'm releasing a new version 0.9.9 on the main thread, which I hope fixes your problem.  Please give it a go!  

As for compiling, I'm using gcc version 4.2.2 and make version 3.8.1.  Maybe you are runing something different that messes up the makefile?

EDIT: fixed typo.
--
Mike L
« Last Edit: September 28, 2009, 12:04:38 AM by MikeLockmoore »

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: flit - battery monitor ineffective, fix
« Reply #4 on: September 28, 2009, 12:09:28 AM »
Thanks for the quick turnaround on this Mike. I'm still on it, too!

0.9.9 on main thread - did you mean on http://forum.tinycorelinux.net/index.php?topic=2818.0 ? ... I hadn't found it there [yet!]

Quote
I see that your battery is reporting "unknown" (a text string) as the rate.  That does not allow the version 0.9.8 and earlier code to parse the rate as a number, so the 'need_rate' var is never set to 1, which prevents the later calculations from running.

Hmm ... that's odd - during get_battery_state(), need_rate is set to 1 at the start of the function. But you're right that the following statement:

Code: [Select]
if(!need_rate && !need_charge && !need_state)

will never be true for my case, since the rate cannot be found.

I was concerned that the section following that 'if(!need_rate && ...) may have its closing bracket in the wrong place - since it never evaluates true for my case, the image never gets updated.

I'm on my way out the door, and will get you a diff of this ASAP.

Offline MikeLockmoore

  • Hero Member
  • *****
  • Posts: 525
  • Good software needn't be big!
Re: flit - battery monitor ineffective, fix
« Reply #5 on: September 28, 2009, 12:32:32 AM »
dentonlt:

Yes, that is the right thread.  Version 0.9.9 should be there when you check again.

Sorry, I mispoke when I said:
Quote
so the 'need_rate' var is never set to 1,

I should have said "'need_rate' is never cleared to 0, so,,,"

I look forward to hearing your results when you have a chance to try 0.9.9.
--
ML

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: flit - battery monitor ineffective, fix
« Reply #6 on: September 28, 2009, 02:56:57 AM »
In short, 0.9.9 works like a champ. There was one unmatched #endif statement at line 69 that catches my make, but a very minor concern. For reference, I've attached my log below.

Thanks for the mention on the other thread, too. Hope the change ends up helping more than just me!

Cheers  :)

EDIT:

OOPS. Okay ... well, almost perfect! 0.9.9 correctly calculates the spare time left on the battery, but doesn't display it when I float my mouse over the battery icon ... dunno why (!). I'll try to figure it out. On the bright side, it's good to know my battery % and see the icon correctly. :)

EDIT: Perfectly normal - suppressing timings for 3 min since 0.9.4.  :D
« Last Edit: September 28, 2009, 03:42:31 AM by dentonlt »

Offline MikeLockmoore

  • Hero Member
  • *****
  • Posts: 525
  • Good software needn't be big!
Re: flit - battery monitor ineffective, fix
« Reply #7 on: September 28, 2009, 01:53:28 PM »
dentonlt:

Great!  :D  I'm happy it works for you now.

I'm not sure why you see a #endif around line #69.  By my count, line 69 is the #ifndef MIN line.  Could it be the soundcard.h include file not balanced?  I did not write that header file and just use it as-is from the OSS published source code.

Here is my code from lines 67 to 73 (version 0.9.9)
Code: [Select]
#include "soundcard.h"

#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a):(b))
#endif

#define APP_VER "0.9.9" // Last update 2009-09-27
--
ML