Contribute
Register

ACPIBatteryManager on XPS 12 (9Q33) in Yosemite

Status
Not open for further replies.

RehabMan

Moderator
Joined
May 3, 2012
Messages
184,624
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Awesome! I pulled all your changes and am running again. Definitely helpful to have the values in decimal rather than hex. Here's some sample output:

...

I ran the coconutBattery to see if there were any clues and I noticed the debug information screen has "Battery1: 0" and "Battery2: 0" along with the Health1 and Health2 not really coming up with anything. Could that be an area to start looking into?

Problem is we don't really know what it is looking for. Or since it is calling system APIs, what the system is looking for or doesn't like about the contents of ioreg for battery.

I could be almost anything, too long of serial#, name, or other detail...

Here's my ioreg battery detais for comparison...

Code:
ProBook-4540s:Projects Admin$ ioreg -r -n  AppleSmartBattery
+-o AppleSmartBattery  <class rehab_ACPIBattery, id 0x1000001f0, registered, matched, active, busy 0 (0 ms$
    {
      "ExternalConnected" = Yes
      "TimeRemaining" = 65535
      "InstantTimeToEmpty" = 65535
      "ExternalChargeCapable" = Yes
      "CellVoltage" = (3124,3124,3124,3126)
      "PermanentFailureStatus" = 0
      "BatteryInvalidWakeSeconds" = 30
      "Voltage" = 12498
      "MaxCapacity" = 4240
      "Quick Poll" = No
      "AtWarnLevel" = No
      "Manufacturer" = "Hewlett-Packard"
      "CurrentCapacity" = 4240
      "LegacyBatteryInfo" = {"Amperage"=0,"Flags"=5,"Capacity"=4240,"Current"=4240,"Voltage"=12498,"Cycle $
      "FirmwareSerialNumber" = 135217
      "BatteryInstalled" = Yes
      "CycleCount" = 93
      "DesignCapacity" = 4240
      "AvgTimeToFull" = 65535
      "ManufactureDate" = 0
      "AtCriticalLevel" = No
      "BatteryType" = "LIon"
      "InstantTimeToFull" = 65535
      "BatterySerialNumber" = "Primary-21031 2011/09/07"
      "PostDischargeWaitSeconds" = 120
      "Temperature" = 2110
      "Serial" = "21031 2011/09/07"
      "InstantAmperage" = 0
      "MaxErr" = 0
      "FullyCharged" = Yes
      "DeviceName" = "Primary"
      "IOGeneralInterest" = "IOCommand is not serializable"
      "Amperage" = 0
      "IsCharging" = No
      "PostChargeWaitSeconds" = 120
      "AvgTimeToEmpty" = 65535
    }
 
Joined
Jan 25, 2014
Messages
81
Motherboard
XPS12
CPU
Haswell i7
Graphics
HD4400
Mac
Classic Mac
Mobile Phone
Problem is we don't really know what it is looking for. Or since it is calling system APIs, what the system is looking for or doesn't like about the contents of ioreg for battery.

I could be almost anything, too long of serial#, name, or other detail...

Here's my ioreg battery detais for comparison...

Code:
ProBook-4540s:Projects Admin$ ioreg -r -n  AppleSmartBattery
+-o AppleSmartBattery  <class rehab_ACPIBattery, id 0x1000001f0, registered, matched, active, busy 0 (0 ms$
    {
      "ExternalConnected" = Yes
      "TimeRemaining" = 65535
      "InstantTimeToEmpty" = 65535
      "ExternalChargeCapable" = Yes
      "CellVoltage" = (3124,3124,3124,3126)
      "PermanentFailureStatus" = 0
      "BatteryInvalidWakeSeconds" = 30
      "Voltage" = 12498
      "MaxCapacity" = 4240
      "Quick Poll" = No
      "AtWarnLevel" = No
      "Manufacturer" = "Hewlett-Packard"
      "CurrentCapacity" = 4240
      "LegacyBatteryInfo" = {"Amperage"=0,"Flags"=5,"Capacity"=4240,"Current"=4240,"Voltage"=12498,"Cycle $
      "FirmwareSerialNumber" = 135217
      "BatteryInstalled" = Yes
      "CycleCount" = 93
      "DesignCapacity" = 4240
      "AvgTimeToFull" = 65535
      "ManufactureDate" = 0
      "AtCriticalLevel" = No
      "BatteryType" = "LIon"
      "InstantTimeToFull" = 65535
      "BatterySerialNumber" = "Primary-21031 2011/09/07"
      "PostDischargeWaitSeconds" = 120
      "Temperature" = 2110
      "Serial" = "21031 2011/09/07"
      "InstantAmperage" = 0
      "MaxErr" = 0
      "FullyCharged" = Yes
      "DeviceName" = "Primary"
      "IOGeneralInterest" = "IOCommand is not serializable"
      "Amperage" = 0
      "IsCharging" = No
      "PostChargeWaitSeconds" = 120
      "AvgTimeToEmpty" = 65535
    }

I went through every value different between our two ioreg outputs and I can't seem to find the culprit. Our Legacy flags are different and such.

Code:
    // Get list of power sources
    CFTypeRef psBlob = IOPSCopyPowerSourcesInfo();
    CFArrayRef psList = IOPSCopyPowerSourcesList(psBlob);

This always returns an empty array for me.

I think what's bothering me most is that this worked in Mavericks for me even without even any DSDT edits and I don't really know what's different now.
 
Joined
Jan 25, 2014
Messages
81
Motherboard
XPS12
CPU
Haswell i7
Graphics
HD4400
Mac
Classic Mac
Mobile Phone
I went through every value different between our two ioreg outputs and I can't seem to find the culprit. Our Legacy flags are different and such.

Code:
    // Get list of power sources
    CFTypeRef psBlob = IOPSCopyPowerSourcesInfo();
    CFArrayRef psList = IOPSCopyPowerSourcesList(psBlob);

This always returns an empty array for me.

I think what's bothering me most is that this worked in Mavericks for me even without even any DSDT edits and I don't really know what's different now.

Well, I've got a fun script for now at least where I can get the percentage of the battery life by doing something like this:

Code:
echo "scale=3; `ioreg -r -n  AppleSmartBattery | awk '/CurrentCapacity/ {print $3}'` / `ioreg -r -n  AppleSmartBattery | awk '/MaxCapacity/ {print $3}'`" | bc
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
184,624
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Well, I've got a fun script for now at least where I can get the percentage of the battery life by doing something like this:

Code:
echo "scale=3; `ioreg -r -n  AppleSmartBattery | awk '/CurrentCapacity/ {print $3}'` / `ioreg -r -n  AppleSmartBattery | awk '/MaxCapacity/ {print $3}'`" | bc

You could also use HwMonitor. It looks directly at the ioreg last I checked.
 
Joined
Jan 25, 2014
Messages
81
Motherboard
XPS12
CPU
Haswell i7
Graphics
HD4400
Mac
Classic Mac
Mobile Phone
You could also use HwMonitor. It looks directly at the ioreg last I checked.

Yep. Downloaded HWMonitor and that at least provides the battery percentage. So are we at a bit of a dead end to make the native battery monitor work? What're next steps?
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
184,624
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Yep. Downloaded HWMonitor and that at least provides the battery percentage. So are we at a bit of a dead end to make the native battery monitor work? What're next steps?

You might try eliminating certain "non-critical" properties from the battery manager...
 
Joined
Jan 25, 2014
Messages
81
Motherboard
XPS12
CPU
Haswell i7
Graphics
HD4400
Mac
Classic Mac
Mobile Phone
You might try eliminating certain "non-critical" properties from the battery manager...

OK, so by eliminating, you mean in the short term just commenting out the "set..." functions calls and just focus on the critical ones? Which are the critical ones? Just setMaxCapacity, setCurrentCapacity, setVoltage, setAmperage?
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
184,624
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
OK, so by eliminating, you mean in the short term just commenting out the "set..." functions calls and just focus on the critical ones? Which are the critical ones? Just setMaxCapacity, setCurrentCapacity, setVoltage, setAmperage?

Pretty much. The obvious critical ones are the ones used to derive a percentage. From this standpoint, there are only two. Of course, the code in OS X probably relies on many more.

If you still have Mavericks installed, it might interesting to start there... See how far you can trim it down in Mavericks until it breaks. That is, if you eliminate one, and it breaks, add it back. After you determine the bare-minimum, go back to Yosemite and try it.
 
Joined
Jan 25, 2014
Messages
81
Motherboard
XPS12
CPU
Haswell i7
Graphics
HD4400
Mac
Classic Mac
Mobile Phone
Pretty much. The obvious critical ones are the ones used to derive a percentage. From this standpoint, there are only two. Of course, the code in OS X probably relies on many more.

If you still have Mavericks installed, it might interesting to start there... See how far you can trim it down in Mavericks until it breaks. That is, if you eliminate one, and it breaks, add it back. After you determine the bare-minimum, go back to Yosemite and try it.

Unfortunately I don't have Mavericks available right now, so I'll have to try the other route. In this testing, is there a way to unload the kext without restarting? I've never been able to do that thus far and if I'm churning through many tests it'd be nice not to have to reboot every time. When I try to unload I get this message:

Code:
(kernel) Can't unload kext org.rehabman.driver.AppleSmartBatteryManager; classes have instances:
(kernel)     Kext org.rehabman.driver.AppleSmartBatteryManager class rehab_ACPIBattery has 1 instance.
Failed to unload org.rehabman.driver.AppleSmartBatteryManager - (libkern/kext) kext is in use or retained (cannot unload).
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
184,624
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Unfortunately I don't have Mavericks available right now, so I'll have to try the other route.

I'm not sure how you determine the bare minimum without a working battery status to begin with.

In this testing, is there a way to unload the kext without restarting? I've never been able to do that thus far and if I'm churning through many tests it'd be nice not to have to reboot every time. When I try to unload I get this message:

Code:
(kernel) Can't unload kext org.rehabman.driver.AppleSmartBatteryManager; classes have instances:
(kernel)     Kext org.rehabman.driver.AppleSmartBatteryManager class rehab_ACPIBattery has 1 instance.
Failed to unload org.rehabman.driver.AppleSmartBatteryManager - (libkern/kext) kext is in use or retained (cannot unload).

I've never tried to unload it. Unloading/reloading probably introduces many problems and is probably not a good idea.
 
Status
Not open for further replies.
Top