--- In [EMAIL PROTECTED], "Aaron Ardiri" <[EMAIL PROTECTED]> 
wrote:
> > > did you try setting your timeout to a non -1 number? if the 
problem
> > > is with SrmRecieveCheck(), bypassing it with a small timeout 
value
> > > could solve your problems as well.
> >
> > Yes.  I have tried multiple timeout values.  SrmReceiveCheck() 
does
> > not return until at least 8 bytes are in the buffer.
> 
> are you saying it thread blocks, or, doesn't return a value until 
there
> are 8 bytes? to quickly test this, try this small adjustment.
> 
>   // Find out if we have bytes in the queue
>   serNumBytes = 0;
>   error = SrmReceiveCheck(m_serRefNum, &serNumBytes);
> 
>   if ((!error) && (serNumBytes))
>   {
>     char serNumBytesChar = serNumBytes + 0x30;  // convert to ASCII
>     FrmCustomAlert(DebugAlert, &serNumBytesChar, NULL, NULL);

In pre-OS 5.0:
  FrmCustomAlert displays 1
In OS 5.0:
  FrmCustomAlert displays 8

>     // Clear the buffer
>     MemSet(m_serUARTBuffer, SER_BUFF_SIZE, 0);
> 
>     // If more bytes are available in UART buffer than we have in 
the
>     // serial message buffer, only get what we have room for.
>     if(serNumBytes > 512)
>       serNumBytes = 512;
> 
>     // Grab bytes from the UART buffer
>     serNumBytes = SrmReceive(m_serRefNum, m_serUARTBuffer, 
serNumBytes, -1,
> &error);
> 
>   }
> 
> that will tell you if it is actually waiting for 8 bytes to come in
> specifically on the SrmReceiveCheck before returning, or, if it 
waits
> for 8 bytes before actually telling you there are some bytes 
available.

If the code is changed to the following:
// Find out if we have bytes in the queue
serNumBytes = 0;
error = SrmReceiveCheck(m_serRefNum, &serNumBytes);
if (!error)
{
  char serNumBytesChar = serNumBytes + 0x30;  // convert to ASCII
  FrmCustomAlert(DebugAlert, &serNumBytesChar, NULL, 
NULL); ..........................

A zero is displayed in the Custom Alert.  Therefore, if there aren't 
bytes in the queue, SrmReceiveCheck() will return immediately in OS 5 
as expected.  But if there are bytes in the queue, SrmReceiveCheck() 
will wait until there are at least 8 before returning, which isn't 
good for my app, becuase it's too late to respond to the poll.

> as for your 'expert' advice, the one guy i know who could answer 
your
> question specifically (who was introduced to me as "mr. serial 
manager")
> probably doesn't work at palm/palmsource anymore due to recent 
layoffs :(
> 
> i am sure many other people here would love to know their expert
> solution to this problem; it seems you were not the only one with
> the problem.
> 
> [digging up old code]
> 
> i found some old code that would grab one byte at a time from the
> serial port, but, it made calls specific to XXXReceiveWait and
> XXXReceive.

We haven't tried this method, but I'll try it out.  Thanks for your 
help!

> ---
>         // wait for byte to arrive
>         error =
> #ifdef USENEWSERMGR
>           SrmReceiveWait
> #else
>           SerReceiveWait
> #endif
>             ((UInt16)serRef, 1, serInterbyteTimeout);
> 
>         // if we had no error, our byte is in the receive queue
>         if (!error)
>         {
>             // receive the byte
>             bytesReceived =
> #ifdef USENEWSERMGR
>               SrmReceive
> #else
>               SerReceive
> #endif
>                 ((UInt16)serRef, rxByte, 1, serReceiveTimeout, 
&error);
> 
>             // see if we received 1 byte and no errors are present
>             if(!error && bytesReceived == 1)
>             {
>                 // set the reception OK flag
>                 receptionOK = true;
>             }
>         } // end if(!error)
> ---
> 
> yet another alternative solution to the problem? while this worked
> on really old units, i have not needed the code on 5.0 units, but,
> this might be another way to tackle the problem?
> 
> ---
> Aaron Ardiri                           [EMAIL PROTECTED]
> CEO - CTO                                              +46 70 656 
1143
> Mobile Wizardry                         
http://www.mobilewizardry.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