Re: SystemPowerState messed up after reboot ...
- From: leobone@xxxxxxxxx
- Date: Tue, 19 May 2009 08:34:42 -0700 (PDT)
One last post on this,
after running in different troubles by not resetting device. I turned
all collected knowledge round and round in the
head, and finally came up with a "SafeHPReset()" function.
This function i can call from "anywhere, when I want" in my
application and it SEEMS to work so far. I'll post it here, just in
case someone else is running into similar problems. There is one
drawback, the device will not reset immediatly, but
with a delay of appprox. 15 seconds.
----- snip ----
void SafeHPReset(){
/* clear any previous scheduled notification, that might have
survived through a user reset */
CeRunAppAtTime(_T("reset_hp_dummy"),NULL);
SYSTEMTIME t;
GetLocalTime(&t);
/* addTime is a helper function */
addTime(&t,15*(1/100e-9));
/* set a notification 15 secs from now,with a dummy app, i dont care,
i just need the device to wakeup */
CeRunAppAtTime(_T("reset_hp_dummy"),&t);
/* poweroff */
GwesPowerOffSystem();
/* any wakeup now where powermanager reports "resuming" do the "HP
workaround" */
TCHAR stateName[20]={0};
DWORD state;
GetSystemPowerState(stateName,20,&state);
if (_tcscmp(stateName,_T("resuming"))==0){
/* !!! The HP powermanager workaround !!! */
SetSystemPowerState(0,POWER_STATE_SUSPEND,POWER_FORCE);
}
/* clear the dummy notification, to avoid notification error
messages after reboot */
CeRunAppAtTime(_T("reset_hp_dummy"),NULL);
/* now powermanager is back on track, and really WILL put it into the
"on" state */
SetSystemPowerState(0,POWER_STATE_ON,POWER_FORCE);
/* from here i get a "nice" reset, unfortunatly i can't use the FLAGS
but need to use the OEM name,
* otherwise it breaks the notification system and i don't get
CNT_TIME notifications triggered any more
*/
SetSystemPowerState(_T("ColdReboot"),0,POWER_FORCE);
}
---- snip ---
ciao larry
On 19 Mai, 11:27, leob...@xxxxxxxxx wrote:
hi chris,
tx for your opinion. i agree with you, only other platform, other
drivers, other conditions,
other OEM system code. if it wouldn't work there either i still would
not know what is wrong. I might even stumble
over totaly different problems.
therefore i was asking here if someone knows about certain conditions
that must be met
when resetting or resuming. since no one suggested anything i assume
that, if the OS
is implemented correctly I should be able to call
SetSystemPowerState(0,POWER_STATE_SUSPEND,0)
or
SetSystemPowerState(0,POWER_STATE_RESET,0)
without compromising system stability at all. As you say those API's
"funnel' in the end
to the same system code, but the codepaths are different and do
certain things in different ways.
tx, for the hint that there is no userspace. what i wanted to say is
that the code in question is running as a "normal"
application. not in a driver or IST.
ciao larry
On 18 Mai, 16:45, "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com>
wrote:
I disagree - knowign would help you a lot. If other harware behaves the
same, you can then be pretty sure there is a problem in your code. If other
harware behaves correctly, then you know it's a platform issue and can start
looking for a workaround instead of trying all of these APIs that all funnel
to the same place in the platform code.
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com
<leob...@xxxxxxxxx> wrote in message
news:c60cad8c-9f24-46d6-a7a6-cf025edd9234@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Chris,
If you mean other Device but same model, yes.
If you mean differrent Model or OEM, no i haven't.
Since I need it to get working on this hardware, it would not help me
much to know
that it is working on some other device. It would only proof my fear
that it is a bug in the OEM's OS implementation.
I then still need to find a workaround.
tx larry
On May 17, 5:56 pm, "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com>
wrote:
Have you tried this on any other hardware as a sanity check?
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com
<leob...@xxxxxxxxx> wrote in message
news:c14a819c-44f3-4063-9abd-7abab02fd7ab@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Bruce,
actually i tried many,many thinkable and unthinkable combinations and
approches.
Also the two that you describe on your blog.
To confirm if i hadn't done somthing wrong i tried
SetCleanRebootFlag();
KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);
again. Well it does not change anything. Actually for the moment i
believe using the in the registry defined OEM PowerState "ColdReboot"
to
be working the most reliable. Using any other method even
ExitWindowsEx causes the notification system not to trigger any
CNT_TIME events after the reboot. At least if
i am using CNT_TIME notifications with named events. But thats
another issue.
In my investigations i found that when the system wakes up, right
after the call to GwesPowerOff(), if i was to put the system straight
into "on"-state the call would either
take about 5-6 seconds and really put the device into "on"-state,
everything how it should be, or would only take ~50ms, report
success, and if you call GetSystemPowerState also report "on" BUT the
PPC
would still be in some unknown state, screen still turned off and
such. It all looks that there are moments while resuming the
PowerManager seems to think the device is full on while it is not. If
in that situation i do a reset,
next reboot everything is quer. Therefore the idea with the second
suspend, wich was a wild guess but actually causes the PowerManger to
get back on track. Only that it has sideffects wich are not
feasible.
I also tried many different versions of how to suspend the device,
from VK_OFF , PPN_POWER_BUTTON_PRESSED, PowerOffSystem(),
SetSystemPowerState(NULL,POWER_STATE_SUSPEND,NULL) the described
symptoms
stay the same.
So maybe there are some restrictions to those apis that i am not aware
of, as i say i have no more ideas.
tx larry
On May 17, 4:33 pm, leob...@xxxxxxxxx wrote:
The reset I do via
SetSystemPowerState(NULL,POWER_STATE_RESET,NULL);
when I handle the wakeup event.
On May 17, 4:21 pm, "Bruce Eitman [eMVP]"
<bruce.eitman.nos...@xxxxxxxxxxxxxxxxxxx> wrote:
How are your rebooting the system? The code you show, doesn't do that.
What you show is asuspendfollowed by asuspend.
Take a look
at:http://geekswithblogs.net/BruceEitman/archive/2008/11/25/windows-ce-r...
--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT EuroTech DOT com
My BLOGhttp://geekswithblogs.net/bruceeitman
EuroTech Inc.www.EuroTech.com
<leob...@xxxxxxxxx> wrote in message
news:297d0e14-4397-40c4-b088-638cd5858e8a@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi everyone, as a last resort i got to ask this here.
I am working on an at first sight trival looking application. All it
has to do, put the PPC at a certain time to sleep and at antother
certain time wake it up and reboot the system.
It uses SetUserNotificationEx and a named event to accomplish that.
Now there is one big mystery which i can't get resolved.
After the reset wich is done via SetSystemPowerState the system
boots
very often into a state where all kinds of devices seem to be in a
wrong power state and do not work any more.
False battery values, no working gps reciver and such. If the PPC is
in such state and you put it intosuspend, the screen goes blank but
the backlight stays on and keeps flickering.
I tracked the problem down so far that this depends on the state of
PPC when i issue the reset. It seems some other party, like
repllog.exe, puts the device in some "magic" state and if i issue
the
reset while beeing in that "magic" state this happens. The big
problem
is i can't know if the device is in that "magic" state.
GetSystemPowerState reports normal states like on,unattended or
resuming.
The only "close to a solution" thing i found working was to have
code
like this.
----- snipp ---
GwesPowerOff(); //turn the device off
// as soon as the PPC wakes up again and the thread starts running
//this call,strangly enough, seems to make the PowerManager to get
it's things kinda right
//it wontsuspendthe device!
SetSystemPowerState(NULL,POWER_STATE_SUSPEND,NULL); //
//wait for my event
WaitForSingleObject(hEvt,INFINITE);
---- snip -----
"close to a solution" because this hack breaks other things.
Important to point out is, that the hardware reset button always
reboots the system into a sane state. All I am wondering is, if i
can
achive the same thing via software.
This is happening on aHPiPAQrx5720 WindowsMobile 5.0
Any ideas or information about when and how to savely reset a PPC is
greatly appreciated.
larry- Zitierten Text ausblenden -
- Zitierten Text anzeigen -- Zitierten Text ausblenden -
- Zitierten Text anzeigen -
.
- References:
- SystemPowerState messed up after reboot ...
- From: leobone
- Re: SystemPowerState messed up after reboot ...
- From: Bruce Eitman [eMVP]
- Re: SystemPowerState messed up after reboot ...
- From: leobone
- Re: SystemPowerState messed up after reboot ...
- From: leobone
- Re: SystemPowerState messed up after reboot ...
- From: Chris Tacke, eMVP
- Re: SystemPowerState messed up after reboot ...
- From: leobone
- Re: SystemPowerState messed up after reboot ...
- From: Chris Tacke, eMVP
- Re: SystemPowerState messed up after reboot ...
- From: leobone
- SystemPowerState messed up after reboot ...
- Prev by Date: Re: Development Kit
- Next by Date: Re: Development Kit
- Previous by thread: Re: SystemPowerState messed up after reboot ...
- Next by thread: time measure in microseconds
- Index(es):