On Mon, 11 Jul 2022 at 10:04, Albus Bhruin <[email protected]> wrote:

> On Fri, 8 Jul 2022 at 17:25, <[email protected]> wrote:
>
>> >Synopsis:      apmd - Logging every 10s on AC power with full battery
>> since upgrade to 7.1
>> >Category:      system
>> >Environment:
>>         System      : OpenBSD 7.1
>>         Details     : OpenBSD 7.1 (GENERIC.MP) #3: Sun May 15 10:27:01
>> MDT 2022
>>                          [email protected]:
>> /usr/src/sys/arch/amd64/compile/GENERIC.MP
>>
>>         Architecture: OpenBSD.amd64
>>         Machine     : amd64
>> >Description:
>>
>>
After looking at the apmd code, and I may have got this all wrong as I know
zilch about apmd etc.,
it looks like the problem is in the function

power_status(int fd, int force, struct apm_power_info *pinfo)

Reading data with

if (ioctl(fd, APM_IOC_GETPOWER, &bstate) == 0) {

returns 4 minutes into bstate.minutes_left when the battery is full, which
then triggers the code
to log a message (extraneous code removed from snippet below):

if ( ... ((bstate.battery_state != APM_BATT_CHARGING) &&
                     (bstate.minutes_left && bstate.minutes_left < 15)) ... {
                        if ((int)bstate.minutes_left > 0)
                                logmsg(priority, "battery status: %s. "
bstate.minutes_left = 4 is clearly wrong for a full battery, but was
no problem in the past as the above
check was not being done. I guess this is hardware though other
conditions seem to return the correct
minutes left value. This wouldn't be some integer wrap around issue?
Unless others more knowledgeable on apmd can see a solution, I can
only see a fudge by testing
battery_life as well as/instead of minutes_left which may then have
side effects on other systems.

Output from systat SENSORS in case useful:

SENSOR                                          VALUE  STATUS  DESCRIPTION
cpu0.temp0                                 57.00 degC
acpibat0.volt0                             11.10 V DC          voltage
acpibat0.volt1                             12.37 V DC          current voltage
acpibat0.current0                             65.53 A          rate
acpibat0.amphour0                             5.32 Ah          last
full capacity
acpibat0.amphour1                             0.53 Ah          warning capacity
acpibat0.amphour2                             0.16 Ah          low capacity
acpibat0.amphour3                             5.32 Ah    OK
remaining capacity
acpibat0.amphour4                             5.20 Ah          design capacity
acpibat0.raw0                                   0 raw    OK    battery full
acpiac0.indicator0                                 On          power supply
acpibtn1.indicator0                                On          lid open

Thanks again for any suggestions or comments.

Al

-- 
Albus Bhruin
Scotland

Reply via email to