What module contains the code to detect when the host computer has shifted to battery power?

Message boards : BOINC client : What module contains the code to detect when the host computer has shifted to battery power?
Message board moderation

To post messages, you must log in.

AuthorMessage
Profile Keith Myers
Volunteer tester
Help desk expert
Avatar

Send message
Joined: 17 Nov 16
Posts: 869
United States
Message 93061 - Posted: 4 Oct 2019, 14:57:27 UTC

What module contains the code to detect when the host computer has shifted to battery power?

The "Suspend computer when on battery" setting in the Manager does not work in Linux Ubuntu for PC's that are backed up by a UPS and running the apcupsd daemon. I do not know if this setting is observed in laptops in Linux. It does in Windows. Maybe someone with a laptop running Linux can comment if it works or not.

There is a running daemon in Linux that monitors all devices that can run on battery power. It can be polled for battery level, discharge or charge state and whether the device in on battery power. The daemon upowerd could be used to detect when the host has shifted to battery power.

Where would this detection code be placed in the client?
ID: 93061 · Report as offensive
Richard Haselgrove
Volunteer tester
Help desk expert

Send message
Joined: 5 Oct 06
Posts: 5082
United Kingdom
Message 93067 - Posted: 4 Oct 2019, 21:13:47 UTC - in response to Message 93061.  
Last modified: 4 Oct 2019, 21:16:55 UTC

I think you need to start reading from

https://github.com/BOINC/boinc/blob/master/client/hostinfo_unix.cpp#L195

There is a separate 'client/hostinfo_linux.cpp', but clearly 'on battery' isn't a "move common linux detection functions to separate file."
ID: 93067 · Report as offensive
Profile Keith Myers
Volunteer tester
Help desk expert
Avatar

Send message
Joined: 17 Nov 16
Posts: 869
United States
Message 93068 - Posted: 4 Oct 2019, 22:48:22 UTC - in response to Message 93067.  
Last modified: 4 Oct 2019, 22:49:10 UTC

I think you need to start reading from

https://github.com/BOINC/boinc/blob/master/client/hostinfo_unix.cpp#L195

There is a separate 'client/hostinfo_linux.cpp', but clearly 'on battery' isn't a "move common linux detection functions to separate file."

OK, thanks I don't know how I missed that file. Seems to have the same structure as the unix one.
So we need to add a new method upower to static enum? Then look for status of "discharging" or power state "2" in the upower state?
ID: 93068 · Report as offensive
Profile Keith Myers
Volunteer tester
Help desk expert
Avatar

Send message
Joined: 17 Nov 16
Posts: 869
United States
Message 93069 - Posted: 4 Oct 2019, 23:25:29 UTC - in response to Message 93068.  

I asked for help from the Ubuntu Launchpad Upower package developer team.
https://answers.launchpad.net/ubuntu/+source/upower/+question/684706
ID: 93069 · Report as offensive
Richard Haselgrove
Volunteer tester
Help desk expert

Send message
Joined: 5 Oct 06
Posts: 5082
United Kingdom
Message 93071 - Posted: 5 Oct 2019, 9:01:02 UTC - in response to Message 93069.  

Ideally, you would be querying their module via an API, rather than reading from a file (even though that's the antedeluvian method BOINC developers prefer).

Please ensure that any code patches you supply are as generic as possible across the *nix domain, not just limited to the 'U' variant. Apart from the laptop case (has anyone tested that under Linux?), the devs will mainly think of UPSs in the context of servers powered by Scientific Linux (becoming obsolete - forget that one), CentOS, Redhat etc.
ID: 93071 · Report as offensive
Profile Keith Myers
Volunteer tester
Help desk expert
Avatar

Send message
Joined: 17 Nov 16
Posts: 869
United States
Message 93101 - Posted: 6 Oct 2019, 4:42:02 UTC - in response to Message 93071.  

Ideally, you would be querying their module via an API, rather than reading from a file (even though that's the antedeluvian method BOINC developers prefer).

Please ensure that any code patches you supply are as generic as possible across the *nix domain, not just limited to the 'U' variant. Apart from the laptop case (has anyone tested that under Linux?), the devs will mainly think of UPSs in the context of servers powered by Scientific Linux (becoming obsolete - forget that one), CentOS, Redhat etc.

Well I certainly am not one to come up with code. I can barely follow what any code does. I have asked Vitali Koshura to take a look at the code. He is one of our BOINC Linux contributors/developers and also happens to develop/contribute for Gridcoin.

I found this web page about Upower. http://www.linuxfromscratch.org/blfs/view/svn/general/upower.html

At the bottom they mention "libupower-glib.so contains the UPower API functions."

So if you say it is preferred to access the function via an API I wonder if this library is the key.

Or possibly through the D-Bus API. https://upower.freedesktop.org/docs/ref-dbus.html

Hope either the Upower developers see my query and offer some guidance or that Vitali has time to look into the matter.
ID: 93101 · Report as offensive

Message boards : BOINC client : What module contains the code to detect when the host computer has shifted to battery power?

Copyright © 2024 University of California.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.