|
misc |
Bits /
PalmThese are some useful bits and pieces I've found while sifting the web for PalmOS/Treo programming info. StyleTap hardware device idStyleTap identifies itself as 'winm'. Other PalmOS tips pageshttp://palm.nanika.net/dev.html has some good info. Dealing with Link Error : Undefined "__cxa_vec_new" for your ARMletThese ABI functions are in C:\Program Files\Metrowerks\CodeWarrior\CW for Palm OS Support\(ARMlet Support)\(Source)\ia64abiruntime.cpp Getting USB device debugging working on CodeWarrior 9Basically, the file USBPort.dll that you will find in WINDOWS\System32 should probably be in PROGRAMFILES\Palm. Also shut down the HotSync manager temporarily. http://palmos.combee.net/blog/USBDebuggingandtheTreo650.html Detecting Treoness/** > * This is the Handspring feature id. Apps can tell if they're on > * a handspring device if they get 0 err back from: > * err = FtrGet (hsFtrCreator, hsFtrIDVersion, &value) > **/ > #define hsFtrCreator 'hsEx' Should also check for PalmOS version >= 5 Screenshot grabbingSee http://www.mail-archive.com/palm-dev-forum@news.palmos.com/msg101749.html Determining if the LCD screen is on
UInt32 v;
if (!HsAttrGet(hsAttrDisplayOn, 0, &v) && v) {
/* screen is on */
}
To find out what the crash log saysopen the Phone application in dial pad view and enter #*377 (sharp, asterisk, three, seven, seven), then press the green send key. Changing the stack size in PNOlet/ARMlet with CodewarriorSee http://news.palmos.com/read/messages?id=193510 IMPORTANT! note from Brennan: turn off auto-inlining! or else your NativeFuncGuts might get inlined and it will crash on app exit
#define stackSize 8192
unsigned long NativeFunc(const void *emulStateP, void *userData68KP,
Call68KFuncType *call68KFuncP){
register void* mem;
register void* oldSP;
register unsigned long ret=stackSize;
mem=MemPtrNew(stackSize);
asm(
MOV oldSP,SP
ADD SP,mem,ret
);
ret=NativeFuncGuts(emulStateP,userData68KP,call68KFuncP);
asm(
MOV SP,oldSP
)
MemPtrFree(mem);
return ret;
}
//replace you main entry point with this one, and call your main entry
point "NativeFuncGuts"
stack size is set in bytes in the "define" on top
Changing the stack size in PNOlet/ARMlet with GCCSee http://news.palmos.com/read/messages?id=194888
//void swapstack(void* newstack, uint32_t size)
.align 2
.global swapstack
.type swapstack, %function
swapstack:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 1, uses_anonymous_args = 0
mov ip, sp
stmfd sp!, {r4, r5, fp, ip, lr, pc}
sub fp, ip, #4
sub sp, sp, #8
str r0, [fp, #-24]
str r1, [fp, #-28]
ldr r5, [fp, #-24]
ldr r4, [fp, #-28]
mov r2,sp
add sp,r5,r4
bl exec_with_new_stack
mov sp,r2
ldmea fp, {r4, r5, fp, sp, pc}
Segment 0
__LoadAndRelocate__ = undocumented runtime library call that swaps in
the other segments (for alarm callbacks etc)... not globals but other
segments ok
Pass true as the first argument to load/lock code segments, and false to unlock
unload segments.
SysAppInfoType *appInfoP = NULL;
SysAppInfoType *rootAppInfoP = NULL;
appInfoP = SysGetAppInfo(&rootAppInfoP, &appInfoP);
/* Relocate multi-segment applications */
MTWK::__LoadAndRelocate__(false, appInfoP->codeH);
http://www.mail-archive.com/palm-dev-forum@news.palmos.com/msg97016.html
_CW_SetupExpandedMode ( );
if ( !(launchFlags & sysAppLaunchFlagNewGlobals) )
{
SysAppInfoType *appInfoP = NULL;
SysAppInfoType *rootAppInfoP = NULL;
appInfoP = SysGetAppInfo(&rootAppInfoP, &appInfoP);
/* Relocate multi-segment applications */
MTWK::__LoadAndRelocate__(true, appInfoP->codeH);
}
//---
SMSintercept sms: "its part of phonelib, register for phnServiceSMS using PhnLibRegister then your application will be launched with launchcode phnLibLaunchCmdEvent and in its parameter you will get event phnEvtMessageInd when new sms arrives" Treo hard buttonsvolume buttons: intercept hsChrVolumeUp/Down PNOSemaphoreNot totally sure what this is for. I think so you can multithread.
class PNOSemaphore {
public:
PNOSemaphore()
: value(0)
{
}
void lock()
{
while (swap(1) != 0)
SysTaskDelay(1);
}
void unlock()
{
value = 0;
}
private:
int swap(int newvalue)
{
asm volatile(
"swp %0,%0,[%1]\n"
: "=r" (newvalue)
: "r" (&value)
: "cc", "memory");
return newvalue;
}
private:
volatile int value;
Treo GPRS crash when phone was not onHi, I met a similar problem on both Treo 600 and Treo 650 using the HTTP lib with GP RS connections, also reproduced with the HTTPLibTest sample: if the radio was no t on before using the sample, the device would reboot randomly while establishin g the GPRS connection, or right after, or while using it, or even when leaving t he sample. Basically, and as far as I undestood, the trouble is the SIM card is not fully r eady for a GPRS connection right after unlocking. Thus, you can't rely on the Ne tLibOpen() API to simultaneously turn the radio on and establish the GPRS connec tion, as the HTTPLibTest sample does. Instead, you should: - use the PhnLibModulePowered() API to check the radio status - if radio is off, use the PhnLibSetModulePower() API to turn it on - use the PhnLibGetSIMStatus() and PhnLibRegistered() APIs to check the SIM stat us and *wait* for the SIM to be registered and ready Then the NetLibOpen() API can safely establish the GPRS connection. Checking if device has camera
//checking if cam installed
if (DmFindDatabase(cardNo,kCameraLibName) != 0 ||
DmFindDatabase(cardNo,kCamLibName) != 0)
{
hasCamera = true;
}
GSM cell info hackhttp://www.palminfocenter.com/forum/viewtopic.php?t=29294 programmatic power offEvtEnqueueKey( gROMVersion >= 0x32 ? vchrPowerOff : autoOffChr, evtNulKeycode, commandKeyMask ); how to get own phone #http://news.palmos.com/read/messages?id=180708
Char* number = NULL;
PhnAddressList list;
PhnAddressHandle address;
Err err = errNone;
PhnLibOpen(phoneLibrary);
if (IsCDMA())
{
err = PhnLibGetOwnNumbers(phoneLibrary, &list);
if (!err)
{
err = PhnLibAPGetNth(phoneLibrary, list, 1, &address);
if (!err && address)
{
number = PhnLibAPGetField(phoneLibrary,address,phnAddrFldPhone);
MemHandleFree(address);
}
}
}
else
{
err = PhnLibGetOwnNumbers(phoneLibrary, &list);
if (!err)
{
err = PhnLibGetNth(phoneLibrary, list, 1, &address);
if (!err && address)
{
number = PhnLibGetField(phoneLibrary,address,phnAddrFldPhone);
MemHandleFree(address);
}
}
}
if (number)
{
StrCopy(destNumber,number);
MemPtrFree (number);
}
PhnLibClose(phoneLibrary);
}
detect ringer switch on treo
//Set silent mode if running on treo
uint32_t ringSwitch;
HsAttrGet (hsAttrRingSwitch, 0 ,&ringSwitch);
if (hsAttrRingSwitchMute == ringSwitch)
how to launch google mapshttp://www.mail-archive.com/palm-dev-forum@news.palmos.com/msg98739.html |