"Dave Lippincott" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Does POL support the serial port callback?  Instead of a tight loop,
process
> the data as it arrives.
>

if you mean the SetWakeupHandler call then yes, i've done it.
...you can do something like:

class CComPort : public CSerial
{
...
 static void RxIRQHandler(UInt32 dwRefCon);
...
};

Err CComPort::OpenPort()
{
Err err=0;
...
 SrmExtOpen(...
...
 if ((err =
SetWakeupHandler((WakeupHandlerProcPtr)RxIRQHandler,(UInt32)this)) != 0) //
sets up WakeupHandlerProc() for Rx
  return err;

 PrimeWakeupHandler(1);    // wake up for each byte

 return err;
}

// rx irq, called if any data
void CComPort::RxIRQHandler(UInt32 dwRefCon)
{
 Err err;
 CComPort *pCP = (CComPort*)dwRefCon;
 UInt8 *pRxBuf;
 UInt32 dwSize;

...
 for (;;)
 {
        err = pCP->ReceiveWindowOpen(*&pRxBuf,dwSize);
        if (err)
//           handle error
        if (!dwSize) // check if done
            break;

// save byte in some buffer

        pCP->ReceiveWindowClose(dwSize); // close window sending number of
bytes rx
 }

 pCP->PrimeWakeupHandler(1); // init to rx up to buffer size
}

...

NOTE: OS 5 (i think) has problems with SetWakeupHandler...so check into this
...i ended up just polling using a timer event and standard tx/rx
calls...works with
all OSes plus i needed to support bluetooth which is easy then (you cannot
use
SetWakeupHandler for bluetooth)

> ----- Original Message ----- 
> From: "Mark Chauvin" <[EMAIL PROTECTED]>
> To: "Palm Developer Forum" <[EMAIL PROTECTED]>
> Sent: Wednesday, May 05, 2004 9:17 AM
> Subject: Custom event loop in POL
>
>
> > I have a program that needs to constantly monitor the
> > serial port for data.  My old version of the program,
> > written in C w/ PRC-tools, redifined the EventLoop
> > function, but now that I'm using POL and a derivation
> > of the CPalmApp object, what's the right way to do
> > this?  Should I have a function that loops
> > continuously & calls the default event loop if no data
> > is waiting in the serial buffer, or should I redefine
> > the CPalmApp event loop, or is there a more elegant
> > way to do this?
> >
> > Thanks
> > -Mark
> >
> > -- 
> > 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