Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

powertop fails to create saved_parameters.powertop on systems where the value of "current_now" is negative. #167

Open
huburb4n opened this issue Dec 11, 2024 · 0 comments

Comments

@huburb4n
Copy link

A negative value is sometimes used for current while discharging.
In "measurement/sysfs.cpp" at line 83 (v2.15) the rate becomes negative leading to the specified failure.

bool sysfs_power_meter::set_rate_from_current(double voltage)
{
	int current;

	if (!get_sysfs_attr("current_now", &current))
		return false;

	/* current: µA
	 * voltage: V
	 * rate: W */
	rate = (current / 1000000.0) * voltage;
	return true;
}

To fix the issue, use the absolute current value in the rate calculation as below:
rate = (abs(current) / 1000000.0) * voltage;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant