This sounds to me like a structure packing / alignment problem.  If you defined your 
app info type in Codewarrior and allocated it with your device application, the 
packing size is 2.  So, for example:

typedef struct { UInt8 junk; UInt32 moreJunk } MyType;

has size 6.  (There is a SINGLE padding byte added after junk).  However if you do the 
same definition in VC on a desktop, the packing size is 4 and your structure will have 
size 8.  Either explicitly pad the device to 4-byte boundaries, or, more rationally, 
use #pragma pack for your desktop code to override the desktop's default packing.

-bob mckenzie, plamsource pdx

-----Original Message-----
From: Guanghe Pan [mailto:snow_rive@;yahoo.com]
Sent: Sunday, October 20, 2002 11:52 PM
To: Palm Developer Forum
Subject: Conduit - App Info block data error


I have a conduit and get the following problem when I
try to read app Info data from Handheld.

The following structure are app Info structure defined
inside both Palm application and conduit application.

typedef struct
{
 WORD   renamedCategories;
 CHAR   categoryLabels[16][16];
 BYTE   categoryUniqIDs[16];
 BYTE   lastUniqID;
 BYTE   reserved1;
 WORD   reserved2;
 BYTE   sortOrder;
 WORD   MyWord1;
 BOOL   MyBOOL1;
 DWORD  MyDWORD1;
 DWORD  MyDWORD2;
 WORD   MyWordArray1[10][5];
 BYTE   MyByteArray1[20];
 CHAR   MyString1[20][16];
} MyAppInfoType, *MyAppInfoPtr;

Inside the following function

SynchronizeAppInfoBlock(CDbGenInfo& dbInfo,
CBaseTable& rTable, eSyncTypes syncType, eFirstSync
firstSync)

I defined

MyAppInfoPtr pAppInfo;

dbinfo contains App Info data from handheld, and then
get I fill pAppInfo

pAppInfo = (MyAppInfoPtr) dbInfo.m_pBytes;

Then

  tempDWord = pAppInfo->MyDWORD1;
  tempDWord = SwapDWordToIntel(tempDWord);

I can get correct result

but

  tempDWord = pAppInfo->MyDWORD2;
  tempDWord = SwapDWordToIntel(tempDWord);

the result is incorrect

Also MyByteArray1 is incorrect

the correct results should be:

MyByteArray1[0] = 0;
MyByteArray1[1] = 1;
MyByteArray1[2] = 2;
...
MyByteArray1[17] = 17;
MyByteArray1[18] = 18;
MyByteArray1[19] = 19;


But What I got are:

MyByteArray1[0] = 2;
MyByteArray1[1] = 3;
MyByteArray1[2] = 4;
...
MyByteArray1[17] = 19;
MyByteArray1[18] = 'A';
MyByteArray1[19] = 'd';

MyString1 is incorrect too,

The correct results are:

MyString1[0] = "Address"
MyString1[1] = "Phone"
...

But I got:

MyString1[0] = "dress"
MyString1[1] = "one"
...

It seems everything was shifted down 2 bytes.

'A' and 'd' in MyString1[0] was move up to
MyBytesArray1[18] and MyByteArray1[19]

Any Problem here?

I also try to read the app info data as follows

pBuff = (char*)dbInfo.m_pBytes;

and then read each structur member and move the
pointer to the next member, but get the same problem

Thanks for your help.

-Rocky

__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to