Hi all,

I have a problem with reading a database (PDB file) on a Palm and sending
these datas from the Palm to a device on the serial port. I included part of
the code below. More precisely, what happens is that I read the records of a
database on the Palm, and I send the datas on the serial port. 

To find me problem I opened HyperTerminal and I captured the text. What I
found is that all the datas are sent and captured, but some datas are copied
twice. For example, at positions 0x9B, 0x9C, 0x9D, I'm supposed to have the
following datas: 0x18, 0x70, 0xE0, but, I have 0x18, 0x70, 0x70, 0xE0.

As you can see below, datas are copied from variable resP to pDatas. I
verified with the debugger and the datas are ok, there are no datas copied
twice. The for loop is to read all the records (there are 387 records). The
MemHandleNew(1000) is to allow 1000 bytes of memory (each record is 1000
bytes). 

Would anyone have any advice?

Thank you!

Dominique Martel





        UInt16  uiSerialPort;
        LocalID         DBID;
        DmOpenRef       DB;
        char            DBName[] = "001-VMB002-1";
        MemHandle       mHandle;
        CharPtr pDatas;
        VoidHand        resH;
        CharPtr         resP;
        UInt16  uiPos = 0;
        UInt32  uiSize = 0;
        UInt32  nDataSent;


        DBID    = DmFindDatabase(0, "001-VMB002-1");
        if (!DBID)
                return;
                
        DB = DmOpenDatabase(0, DBID, dmModeReadOnly);;
        if (!DB) // DB does not exists 
                return;

        mHandle = MemHandleNew(1000);

        for (uiPos = 0; uiPos < 387; uiPos++)
        {
                pDatas  = MemHandleLock(mHandle);
                if (!pDatas)
                        return;
                
                resH = DmGetRecord(DB, uiPos);
                resP = MemHandleLock(resH);

                uiSize = MemHandleSize(resH);
                MemMove(pDatas, resP, uiSize);
        
                SerReceiveFlush(m_uiSerialPortId, 0);
                nDataSent = SerSend(m_uiSerialPortId, pDatas, uiSize, &err);
                
                if (err)
                        return;
                
                MemHandleUnlock(mHandle);
                MemHandleUnlock(resH);
                DmReleaseRecord(DB, uiPos, true);
        }//end for

        MemHandleFree(mHandle);





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

Reply via email to