Hi,
I am using an external real time clock to store the local time.
Inside RTC_Init(), I start an endless thread waiting for time events
"NOTIFICATION_EVENT_TIME_CHANGE" and "NOTIFICATION_EVENT_TZ_CHANGE" to
be notified about time changes (see code below). This works fine until
Suspend/Resume!
If the board did a Suspend/Resume, I get following errors at bootup:
> Notification Error : Cannot execute \\.\Notifications\NamedEvents\DSTTimeChange
> Notification Error : Cannot execute \\.\Notifications\NamedEvents\TaskbarTimeChangeEvent
Afterwards, a "NOTIFICATION_EVENT_TIME_CHANGE" event occurs.
When I delete my persistent registry, the errors disappear until I do
another Suspend/Resume.
If I disable the RTC driver, no errors are visible at all!
Does anybody know why these errors happen or do I make something wrong
inside my endless thread?
Thanks in advance
beat
DWORD WINAPI synchronizerThread(LPVOID param)
{
HANDLE hTimeEvent[2];
CE_NOTIFICATION_TRIGGER trigger[2];
SYSTEMTIME time;
DWORD rWaitObject;
// Time change
GetLocalTime(&trigger[0].stStartTime);
trigger[0].dwSize = sizeof(CE_NOTIFICATION_TRIGGER);
trigger[0].dwType = CNT_EVENT ;
trigger[0].dwEvent = NOTIFICATION_EVENT_TIME_CHANGE;
trigger[0].lpszApplication = L"\\\\.\\Notifications\\NamedEvents\
\TimeNotify";
trigger[0].lpszArguments = 0;
trigger[0].stEndTime = trigger[0].stStartTime;
// TimeZone change
GetLocalTime(&trigger[1].stStartTime);
trigger[1].dwSize = sizeof(CE_NOTIFICATION_TRIGGER);
trigger[1].dwType = CNT_EVENT ;
trigger[1].dwEvent = NOTIFICATION_EVENT_TZ_CHANGE;
trigger[1].lpszApplication = L"\\\\.\\Notifications\\NamedEvents\
\TimeZoneNotify";
trigger[1].lpszArguments = 0;
trigger[1].stEndTime = trigger[1].stStartTime;
hTimeEvent[0] = CreateEvent(0, FALSE, FALSE, L"TimeNotify");
hTimeEvent[1] = CreateEvent(0, FALSE, FALSE, L"TimeZoneNotify");
if ( (hTimeEvent[0] == 0) || (hTimeEvent[1] == 0) ) {
RETAILMSG(1, (L"External RTC - Creation of TimeEvents failed!\r
\n"));
}
else {
WaitForAPIReady(SH_WMGR, INFINITE);
while (CeSetUserNotificationEx(0, &trigger[0], 0) == NULL)
{ Sleep(200); }
while (CeSetUserNotificationEx(0, &trigger[1], 0) == NULL)
{ Sleep(200); }
while (1) {
rWaitObject = WaitForMultipleObjects(2, hTimeEvent, FALSE,
INFINITE);
if ( (WAIT_FAILED == rWaitObject) ||
(WAIT_TIMEOUT == rWaitObject) )
RETAILMSG(1, (L"External RTC Task -
WaitForMultipleObjects ERROR!\r\n"));
}
else {
EnterCriticalSection(&csRTC);
GetLocalTime(&time);
setExternalRtc(&time);
LeaveCriticalSection(&csRTC);
}
}
}
return 0;
}