IOPSCopyPowerSourcesInfo() does not always work.

Originator:jollysupport
Number:rdar://7327017 Date Originated:22-Oct-2009 07:41 PM
Status:open Resolved:
Product:MacOS X Product Version:10.6.1
Classification:Other Bug Reproducible:Sometimes
 
22-Oct-2009 07:41 PM Patrick Stein:
Summary: IOPSCopyPowerSourcesInfo() returns NULL on a MacBook Pro.

Steps to reproduce: With some (not all) MacBook Pros a call to IOPSCopyPowerSourcesInfo() will return NULL during boot. 
I do have a program that has a LaunchDaemon to be started via launchd . When that daemon is started it tests first for the availability of a battery and doing that via IOPSCopyPowerSourcesInfo(). This call does return NULL at first and a few seconds later works.

Expected:
I should always get back a correct value on a machine with a battery installed.

Workaround:
I now have a workaround in the program ( just retrying every few seconds ( up to a minute) ) but I don't like this kind of approch. 

Notes: The program that uses it is SmartSleep when set to smartsleep. It will spit out this error like this:


22.10.09 18:50:16	de.jinx.SmartSleepDaemon[41]	hibernation.currentstate(
22.10.09 18:50:16	de.jinx.SmartSleepDaemon[41]	): list of powersources is empty).
22.10.09 18:50:16	de.jinx.SmartSleepDaemon[41]	hibernation.currentstate() : did not get IOPSC
22.10.09 18:50:16	de.jinx.SmartSleepDaemon[41]	opyPowerSourcesIn
22.10.09 18:50:16	de.jinx.SmartSleepDaemon[41]	fo()
22.10.09 18:50:16	de.jinx.SmartSleepDaemon[41]	machine_has_battery(): powersystem not in place - waiting.
22.10.09 18:50:21	de.jinx.SmartSleepDaemon[41]	machine_has_battery(): powersystem now up and running.


As you see after 5 seconds its working.


Best Regards - Patrick Stein

---
author of: ScreenRecycler, JollysFastVNC, SmartSleep, SmartSokoban and more

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!