We are using wakeup handler function for recieving data from USB port.

Sample code is as follows

error = SrmExtOpen(serPortCradleUSBPort, &config, sizeof(config),&openPort);

if (!error)

{

error =

SrmSetWakeupHandler(openPort,(WakeupHandlerProcPtr)RecvEventHandler,

(UInt32)openPort);

error = SrmPrimeWakeupHandler (openPort, 1);

}



In handler function we have written following code

static void RecvEventHandler(UInt32 refCon)

{

Err error = 0;

char buf[4];

UInt32 count = 0;

Err err = 0;

UInt8* bufP;

while (true) {

//read the data

err = SrmReceiveWindowOpen(openPort, &bufP, &count);

if (err)

SrmClearErr(openPort);

if (!count)

{

break;

}

if (bufP)

{

//Process the data here.

}

//Let the New Serial Manager know that we're done with the data.

SrmReceiveWindowClose(openPort, count);

}



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

Reply via email to