All,

I have a Palm application that uses the Serial Manager to communicate via
the serial port with another application.  A problem occurs when a large
amount of data is sent to the Palm.  I have a Poll() function that
continuously calls SerReceiveCheck() and then SerReceive() to get data sent
to Palm's internal serial buffer.  When I send a large amount of data
SerReceiveCheck() will return numBytes=0 before all of the sent bytes have
been retrieved.  Does anyone know of any issues with retrieving data from
the serial port and not being able to retrieve all of the data that has been
sent.  I have also implemented this with the new serial manager, but that
yielded the same results.


Here is a block of my code:

setBufferSize()
{
        // I have tried increasing BUFFERSIZE incrementally from the default (512)
to
        // 20K, and this had no effect
        SerSetReceiveBuffer(anr,_SerBuffer,BUFFERSIZE);
}

configurePort()
{       Err err = SerOpen(anr, SERIALPORT, _BaudRate);
        if (err == 0)

                SerSettingsType settings;
                SerGetSettings(_SerialLibNum, &settings);
                settings.baudRate = _BaudRate;  // baud rate
                // We want 8N1
                settings.flags = serSettingsFlagBitsPerChar8;
                settings.flags |= serSettingsFlagStopBits1;
                // Turn on hardware handshaking (since we're above 19200 baud)
                settings.flags |= serSettingsFlagRTSAutoM;
                settings.flags |= serSettingsFlagCTSAutoM;
                settings.ctsTimeout = serDefaultCTSTimeout;
                err = SerSetSettings(_SerialLibNum, &settings);
        }
}

bool Poll()

        if (_SerialLibNum == 0) return false;
        // Check serial port for incoming data
        UInt32 numBytes = 0;
        Err err = SerReceiveCheck(_SerialLibNum, &numBytes);
        if (err) {
                errorHandler(err);
                return false;
        }

        // SerReceiveCheck() will return numBytes equal to zero, before all of the
bytes sent have actually
        // been retrieved


        if (numBytes > 0)

                // Get as many bytes as are there
                UInt32 num = std::min(numBytes, _Expected - _Received);
                UInt32 received = SerReceive(_SerialLibNum, (void*)(_Incoming +
_Received), num, -1, &err);
                if (err) {
                        errorHandler(err);
                        return false;
                }

                _Received += received;

                // We are expecting a message. Do we have it?
                if (_Received >= _Expected) {
                        // We are done
                        // Set _Expected back to 0 for next go-around
                        // Do something with _Incoming buffer because we have the 
entire message
                        _Expected = WAITING;
                        delete[] _Incoming;
                        _Incoming = 0;
                }
        };
        return false;
};




Thanks,
Dave



****************************************************************
Dave Ripley                       Syclo LLC
Software Engineer
****************************************************************


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

Reply via email to