Hello,
We're having a problem with alarms. We are
using Palm IIIx, PalmOS 3.1.
We set an alarm for 60 seconds and go to sleep.
When we receive the alarm, if a certain condition
has been met, we resume execution of the program.
If the condition has not been met, we go back to
sleep for another 60 seconds. This seems to work
fine in the emulator, but it fails in a real Palm device.
We get the fatal message:
"MemoryMgrNew.c, Line: 4128, Invalid handle."
Can anyone suggest a reason why this is failing?
Are there problems with HwrSleep() and HwrWake()?
Is HwrWake() even needed in this context?
Here's the code. When a certain condition occurs,
we set an alarm and go to sleep:
Label:
iValue = DoTest();
if ( iValue <= NUMBER)
{
UInt cardNo = 0;
LocalID dbID;
DmSearchStateType searchInfo;
ULong uWhen;
uWhen = uNow + 60;
DmGetNextDatabaseByTypeCreator ( true, &searchInfo,
0, kProgramCreator, true, &cardNo, &dbID );
err = AlmSetAlarm ( cardNo, dbID, 0, uWhen, false );
HwrSleep ( false, false );
// This is where we'll be after waking up.
// Now turn off the alarm (it may already be off).
err = AlmSetAlarm ( cardNo, dbID, 0, 0, false );
goto Label;
}
In PilotMain(), here's how we handle the alarm:
case sysAppLaunchCmdAlarmTriggered:
{
SysAlarmTriggeredParamType *pPB;
UInt iValue;
pPB = (SysAlarmTriggeredParamType *) cmdPBP;
// We don't need to get sysAppLaunchCmdDisplayAlarm
pPB->purgeAlarm = true;
iValue = DoTest();
if ( iValue > NUMBER)
{
HwrWake ();
}
else
{
UInt cardNo = 0;
LocalID dbID;
DmSearchStateType searchInfo;
ULong uWhen;
Err err;
uWhen = TimGetSeconds() + 60;
DmGetNextDatabaseByTypeCreator ( true, &searchInfo,
0, kProgramCreator, true, &cardNo, &dbID );
// Sleep for another minute.
// Actually, this is probably unnecessary, since the alarm
// will be reset in the module above
err = AlmSetAlarm ( cardNo, dbID, 0, uWhen, false );
}
}
Greg Bungo
[EMAIL PROTECTED]
(630)949-3250 voice
(630)949-3299 fax
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html