Maybe someone knows a better way to get the device emulator to suspend and resume, but since that wasn't my end goal this is a story of what I did to get the emulator to resume.
I am sitting in a hotel room with nothing much to do so I thought it would be a good time to add power management capabilities to my Windows CE: A Stream Interface Driver Shell. I brought a device with me, and I have everything I need to use it, except a cable to connect to the serial debug port which I need. So since I already have a device emulator project sitting in my WINCE600 folder from a demo that I did last year, I decided to dust it off and use it.
I started up my emulator and looked around to see if there was an obvious way to suspend and resume it. Of course there is a Suspend in the Start menu, so I tried it. The emulator did suspend, it even closed the window. I was thinking that it might just give me an option to resume once it had suspended, but that wasn't the case. Worse, after suspending I couldn't reattach because the emulator was still running. I had to kill the process before I could use it again.
I have a little application that uses CeRunAppAtTime() which will wake up a real device that has a Real Time Clock (RTC) capable of waking the CPU. So I tried that. The same thing happened, the emulator suspended and the windows closed. After waiting a while for the RTC to wake it back up, I killed the emulator again.
Again, resuming the device emulator wasn't my end goal. So it was time for a quick and dirty solution. I edited OEMPowerOff() in the OAL to remove the line of code that actually suspends the emulator. The line that I removed was a call to CPUPowerOff(). With this change, the emulator will suspend and immediately resume because it doesn't put the CPU into a low power state.
This little modification comes in handy for testing behavior of software on suspend and resume. So I could work on the power management in DriverShell, which doesn't really control any hardware. This could also be used for testing an application.
Copyright © 2008 – Bruce Eitman
All Rights Reserved