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

Add NotCharging state #16

Closed
wants to merge 1 commit into from
Closed

Conversation

denysvitali
Copy link

Apparently my notebook reports the Not Charging status as well, this PR adds the status so that the tool won't return an error when this status is seen.

dvitali@denvit-ws1:power_supply/BAT0 $ pwd
/sys/class/power_supply/BAT0
dvitali@denvit-ws1:power_supply/BAT0 $ cat status
Not Charging

@KenjiTakahashi
Copy link
Member

Thanks for the PR!
Indeed, it looks that such state exists in Linux specification. I am wondering why, though? What does it represent? Batteries are not "stable", they are always charging or discharging (or empty and not connected to power source).
I don't want to expose some "artificial" state to the API, not without knowing what it means. Unfortunately, I couldn't find any details in kernel docs, maybe the source would shed some light? I'll try looking into it.

@denysvitali
Copy link
Author

Well, I was impressed as well. Maybe it's due to the fact that some controllers are able to disable battery charging when they notice that the battery is fully charged, to avoid compromising the battery lifetime, therefore they disable the battery and solely rely on AC.

I mean, I'm not sure, this is just a wild guess :)

@lnu
Copy link

lnu commented May 25, 2021

Same issue here. Under wsl in windows 10(ubuntu 20.04 lts)

@KenjiTakahashi
Copy link
Member

I've been revisiting this code recently, as I'm working on a course about OS-level Go programming. [I've been meaning to do it for a long time anyway, but there were many other things happening, and this gave me some more push.]

There are few things of note here.
After looking through the kernel code, it looks like the status (pseudo-)file can sometimes be RW. Apparently there are controllers that allow switching charging on/off through software. Which on Linux means writing state string to the status. That said, nowadays different drivers tend to use the "Not Charging" state more freely, e.g. to indicate stuff like described in #23.

Another thing I remembered is that OpenBSD also has similar state, called "battery idle". The package currently coerces it to Unknown.

Personally, I'm leaning towards the "Idle" name, it seems the most neutral to me. Doesn't provoke the question "Why?" in my head, like "Not Charging" or "On Hold".
Either way, I plan to push some refactors in the coming days, that should also fix these issues.

@denysvitali
Copy link
Author

Switching branches, closing this one.

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

Successfully merging this pull request may close these issues.

None yet

3 participants