Wednesday, 29 September 2010

Using events and waking devices using CeRunAppAtTime

Want to wake up a CE device at a future time (even if it is suspend), then use the CeRunAppAtTime but instead of running an app use a named event, this allows an application to wake up the device at a set time and also trap the wake event without spawning another process:

SYSTEMTIME time;
CTime nextWakeUpTime;

// get local system time and convert time to CTime for now
GetLocalTime(&time);
CTime now(time);

// 30 minutes in the future
nextWakeUpTime=now;
nextWakeUpTime+=CTimeSpan(0,0,30,0);

// convert to systemtime
nextWakeUpTime.GetAsSystemTime(time);

// set for wake up !
CeRunAppAtTime(TEXT("\\\\.\\Notifications\\NamedEvents\\SCHEDULE_WAKEEVENT_EVENT"), &time);

HANDLE wakeEvent = CreateEvent(NULL, FALSE, FALSE, SCHEDULE_WAKEEVENT_EVENT);

// wait for wake up!
if (WaitForSingleObject(wakeEvent, FALSE, INFINITE) == WAIT_OBJECT_0)
{
// sheduled wake up
}

Friday, 10 September 2010

KITL Messages Don't Support Wide Strings

I've just tracked down a minor irritation with KITL_RETAILMSG and KITL_DEBUGMSG under CE 6.0 R3 - they can't print UNICODE or wide strings.

On several platforms I've seen the KITL device name is not printed correctly. The device name is the name member of the OAL_KITL_DEVICE structure and is defined as a LPCWSTR.

Typically OALKitlInit uses KITL_RETAILMSG to report the device name but the name is never displayed correctly. The string is formatted as "%s" but only the first letter is shown - this implies that the wide string is being formatted as a character string. Trying %hs or %S to override the default does not help.

Reviewing the private sources confirms the problem. Only the %s format is supported and this is for character strings only.

Also be aware that formatting such as %08x is not supported either, but %X is fine!

Monday, 6 September 2010

Using #include from BIB files



Did you know that inside of Windows CE build system that bib files can #include other bib files. This technique is used on many BSP's to implement individual driver registry entries from the driver directory

platform.reg
#include "$(_TARGETPLATROOT)\SRC\DRIVERS\display\display.reg"

The same can be done for the bib file, I didn't release this before, but its there to use if you want to in CE6.0 for sure!

platform.bib
#include "$(_TARGETPLATROOT)\SRC\DRIVERS\display\display.bib"