Patches applied.
Thank You for your contribution.
-Chris

On 02/24/2012 08:50 AM, Paul Menzel wrote:
> Dear Jaroslav,
>
>
> Am Freitag, den 24.02.2012, 16:00 +0100 schrieb Jaroslav Škarvada:
>> Proposed fix for firmwares that provides POWER_NOW instead of CURRENT_NOW.
> thank you for the patch. Could you elaborate on the problem you are
> addressing and add maybe a link to more information about the difference
> between POWER_NOW and CURRENT_NOW?
>
>> ---
>>   measurement/power_supply.cpp |   30 ++++++++++++++++++++++--------
>>   1 files changed, 22 insertions(+), 8 deletions(-)
>>
>> diff --git a/measurement/power_supply.cpp b/measurement/power_supply.cpp
>> index b4fe3af..f7ad964 100755
>> --- a/measurement/power_supply.cpp
>> +++ b/measurement/power_supply.cpp
>> @@ -76,7 +76,8 @@ void power_supply::measure(void)
>>      char line[4096];
>>      ifstream file;
>>
>> -    double _rate = 0;
>> +    double _power_rate = 0;
>> +    double _current_rate = 0;
>>      double _capacity = 0;
>>      double _voltage = 0;
>>
>> @@ -114,11 +115,21 @@ void power_supply::measure(void)
>>                      c = strchr(line, '=');
>>                      c++;
>>                      if(*c == '-') c++; // ignoring the negative sign
>> -                    _rate = strtoull(c, NULL, 10);
>> +                    _current_rate = strtoull(c, NULL, 10);
>>                      if (c) {
>> -                            //printf ("CURRENT: %f. \n",_rate);
>> +                            //printf ("CURRENT: %f. \n",_current_rate);
>>                      } else {
>> -                            _rate = 0;
>> +                            _current_rate = 0;
>> +                    }
>> +            }
>> +            if (strstr(line, "POWER_NOW")) {
>> +                    c = strchr(line, '=');
>> +                    c++;
>> +                    _power_rate = strtoull(c, NULL, 10);
>> +                    if (c) {
>> +                            //printf ("POWER: %f. \n",_power_rate);
>> +                    } else {
>> +                            _power_rate = 0;
>>                      }
>>              }
>>              if (strstr(line, "CAPACITY=")) {
>> @@ -152,10 +163,13 @@ void power_supply::measure(void)
>>              voltage = 0.0;
>>      }
>>
>> -    if(_rate) {
>> -            _rate = _rate / 1000.0;
>> -            _rate = _rate * _voltage;
>> -            rate = _rate;
>> +    if(_power_rate)
>> +    {
>> +            rate = _power_rate / 1000000.0;
>> +    }
>> +    else if(_current_rate) {
>> +            _current_rate = _current_rate / 1000.0;
>> +            rate = _current_rate * _voltage;
> The coding style in the hunk above seems to use spaces.
>
>>      } else {
>>              rate = 0.0;
>>      }
>
> Thanks,
>
> Paul
>
>
> _______________________________________________
> Power mailing list
> Power@bughost.org
> https://bughost.org/mailman/listinfo/power

_______________________________________________
Power mailing list
Power@bughost.org
https://bughost.org/mailman/listinfo/power

Reply via email to