Hi everybody,

The code below works perfectly under PalmOS 3.5.2 and it does not under 4.0.
Timeout occurs here:
     bytesRcvd = SrmReceive(portId, bufP, maxRcvBlkSize, waitTime, &err);
waitTime is long enough here. SrmReceive returns 0 (bytes received).

Please look through the code. Any advice is appreciated.

Err RcvSerialData(UInt8 *serQP, UInt32 *serQueSizeP,
         UInt8 *bufP, UInt32 *bufSizeP,
         UInt32 *lineStatusP, UInt16 *lineErrsP)
{
  UInt32 maxRcvBlkSize, bytesLeft, bytesRcvd=0, waitTime,
    totalRcvBytes = 0;
  UInt32 flags, numSent, twoByteCmd=2;
  UInt16 portId, paramSize;
  Err err = 0;
  Char charCmd[2];
  Boolean serPortOpened = false;

  err = SrmOpen(serPortCradlePort, 115200, &portId);
  if (err) goto ReceiveError;
  serPortOpened = true;
  err = SrmSetReceiveBuffer(portId, serQP, *serQueSizeP);
  if (err) goto ReceiveError;
  flags = srmSettingsFlagBitsPerChar8
     | srmSettingsFlagStopBits1
     | srmSettingsFlagRTSInactive;
  paramSize = sizeof(flags);
  err = SrmControl(portId, srmCtlSetFlags, &flags, &paramSize);
  if (err) goto ReceiveError;
  maxRcvBlkSize = *bufSizeP;
  bytesLeft = *bufSizeP;
  waitTime = SysTicksPerSecond() * (DAQ_TIME * 2);

  do {
    if (bytesLeft < maxRcvBlkSize)
      maxRcvBlkSize = bytesLeft;
    bytesRcvd = SrmReceive(portId, bufP, maxRcvBlkSize, waitTime, &err);
<<<<<
    totalRcvBytes += bytesRcvd;
    bytesLeft -= bytesRcvd;
    serQP += bytesRcvd; // Advance the serQP.
    if ((err == serErrTimeOut) && (bytesRcvd == 0))
      goto ReceiveError; // ...bail out and report the error.
    if ((err) && (err != serErrTimeOut))
      goto ReceiveError;
  } while (bytesLeft);

  ReceiveError:
  if (!err==0 & serPortOpened) {
   SrmGetStatus(portId, lineStatusP, lineErrsP);
  }
  if (serPortOpened) {
  SrmReceiveFlush (portId, 0);
    SrmSetReceiveBuffer(portId, 0L, 0);
    SrmClose(portId);
  }
  *bufSizeP = totalRcvBytes;
  return err;
}




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

Reply via email to