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

Message boards : BOINC Manager : 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 93056 - Posted: 4 Oct 2019, 7:20:20 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. 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 or the Manager?
ID: 93056 · Report as offensive
Richard Haselgrove
Volunteer tester
Help desk expert

Send message
Joined: 5 Oct 06
Posts: 5081
United Kingdom
Message 93059 - Posted: 4 Oct 2019, 10:18:56 UTC - in response to Message 93056.  

Detection will be done in the client. The Manager is simply a 'command and control' module, allowing the user to see data and configure settings (like whether battery status is allowed to change processing state).

More seriously, I don't know enough about the internal workings of either Linux or Windows to verify whether the 'external UPS' case is handled through exactly the same pathway as the 'internal laptop primary power' case. That needs nailing down first.
ID: 93059 · Report as offensive
Profile Keith Myers
Volunteer tester
Help desk expert
Avatar

Send message
Joined: 17 Nov 16
Posts: 869
United States
Message 93060 - Posted: 4 Oct 2019, 14:51:41 UTC - in response to Message 93059.  

So who would know where the code resides. I have tried searching on "battery" in the client directory and found no hits. So that keyword is not a variable in the code it seems. What would the "on battery" algorithm variable be called?

This issue mentions what the Windows API is using. https://github.com/BOINC/boinc/issues/1471
I added comments to this issue. But nothing in the issue points me to where the code resides.
ID: 93060 · Report as offensive
Richard Haselgrove
Volunteer tester
Help desk expert

Send message
Joined: 5 Oct 06
Posts: 5081
United Kingdom
Message 93062 - Posted: 4 Oct 2019, 18:22:48 UTC - in response to Message 93060.  

Sorry, I've had an unexpectedly busy day. I'll try and find time over the weekend to have a ferret around.
ID: 93062 · Report as offensive
Profile Keith Myers
Volunteer tester
Help desk expert
Avatar

Send message
Joined: 17 Nov 16
Posts: 869
United States
Message 93066 - Posted: 4 Oct 2019, 21:01:58 UTC

Finally have managed some usable search output. I think the module that we need to be concerned with is the boinc-client_release-7-7.16/client/hostinfo_unix.cpp file.

It should work if the search for the interfaces was up to date. It doesn't appear so. The code looks like it was current for the BOINC Linux 7.4.22 app. None of the interfaces it checks are using the current Linux naming or locations.
Lines 223 through 364.

We need to change the interrogation to the upower interface.
upower -i /org/freedesktop/UPower/devices/ups_hiddev0

native-path:          /sys/devices/pci0000:00/0000:00:08.1/0000:0d:00.3/usb9/9-4/9-4:1.0/usbmisc/hiddev0
  vendor:               American Power Conversion 
  model:                Smart-UPS_1500 FW:UPS 03.5 / ID=1015
  serial:               3S1831X12519    
  power supply:         yes
  updated:              Fri 04 Oct 2019 01:58:57 PM PDT (23 seconds ago)
  has history:          yes
  has statistics:       yes
  ups
    present:             yes
    state:               charging
    warning-level:       none
    time to empty:       11.7 minutes
    percentage:          98%
    icon-name:          'battery-full-charging-symbolic'
ID: 93066 · Report as offensive
Richard Haselgrove
Volunteer tester
Help desk expert

Send message
Joined: 5 Oct 06
Posts: 5081
United Kingdom
Message 93128 - Posted: 8 Oct 2019, 7:18:47 UTC - in response to Message 93066.  

I think it would be better to continue this discussion in the 'BOINC client' version of this thread.
ID: 93128 · Report as offensive

Message boards : BOINC Manager : 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.