I'm using a simple derivation of Neil Rhodes GPS program nilEvent loop
processing to receive serial data. I just put up this little loop and I cause a
nasty error on POSE. 

I receive the data fine if I'm walking the code in the debugger - assuming my
device has sent any - but when I return to the do loop from the statement: 

     while (!EvtSysEventAvail(false));

I get an nasty error: "MyApp" has just read directly from memory location zero (NULL).

If I select Continue or Debug, I get another error dialog: "MyApp" has just
perormed an illegal operation. It performed a "tracae".

Where exactly did I do these things?  I'm confused.

Here's my nilEvent loop, part of my form event loop:
----------------
// interesting local variables
 ULong   numBytesPending;
 ULong   numBytes;
 Err     err;
 char    receiveData[100];

case nilEvent:
  handled = true;
                        
  if (gCommEnabled)     // set if serial comm init OK
  {
    // keep checking for data until another event arrives
    do {        
       err = SerReceiveWait(gSerialRefNum, sizeof(receiveData)-1, 30);
       if (err == serErrLineErr) 
       {
         // We had an error, so clear it, flush the buffer and try again
         SerReceiveFlush(gSerialRefNum, 1);
         continue;
       }
       err = SerReceiveCheck(gSerialRefNum, &numBytesPending);
       if (err == serErrLineErr) 
       {
         // We had an error, so clear it, flush the buffer and try again
         SerReceiveFlush(gSerialRefNum, 1);
         continue; 
       }
       if (numBytesPending > 0)
       {
         numBytes = SerReceive(gSerialRefNum, receiveData, 
            numBytesPending, 0, &err);
       }
    } while (!EvtSysEventAvail(false));
  }
  break;
----------------
Any ideas where to look?  All my variables appear to be correctly defined,
assigned and initialized. The Serial port is opening fine. I'm using the
defeault buffer size and only receiving 3 characters so far - yes they are my
characters so I know the serial port stuff is at least working a little :).

Thanks,

-Tim
-- 
Tim Hewitt
Principal Software Engineer
Fairchild Semiconductor

Reply via email to