1) I would reduce the timeout value in SerReceiveFlush to something
smaller,. (unless your chars are being transmitted 1 every 2-3 secs)
2) Depending on the actual Palm device you use... You may need to delay
50-65ms after opening the serial port before your remote devices transmits.
3) I understand you are only receiving but, the Pro/PS transmit 0x08 when
the port is opened (this could screw up the other end if you're not
expecting it)
4) Personally, I've had better success receiving chars if you look for
single chars rather than whole strings.
instead of :
serError = SerReceive(serRefNo, buffer, 6, 10000, &serError);
if(serError != 0)

    FrmCustomAlert(altNotice, "Error", "Receive error.", " ");

use something like:
StartTime = TimGetTicks()
do{
    SerReceiveCheck(lib, &Bytes);
    if(Bytes)
        Done = true;
    EndTime = TimGetTicks();
    }while ((Done == false) && ((EndTime-StartTime) <= WAITTIMEOUT))
if(Done == false)
    return 0;
StartTime = TimGetTicks();
BytesReceived = 0;
do{
    Bytes = SerREceive(lib,&localBuffer,1,0,&error);
    if(Bytes)
        {
        // process your bytes, look for end condition (end of line or # of
bytes)
        // or copy byte to your return buffer
        }
    else
        {
        EndTime = TimGetTicks();
        }
    }while((EndTime - StartTime) <= TIMEOUT);

Its a little more involved than just waiting for 7 chars, but I seemed to
loose chars while waiting for more than one byte.


-----Original Message-----
From: Mike Davis <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Sunday, September 26, 1999 11:13 PM
Subject: Serial I/O Problem - READ FIRST - Disregard my previous


I am resending this as I had an obvious error that I
don't want to sidtrack people who are trying to help.

This is a receive problem...

I am having problems with some code to read serial i/o.
I only have to receive; don't need to transmit.
My parameters are 19200, None, 7 data bits, 1 stop bit.

I can see that the serial i/o receives something but there
must be something I am missing in setting up the port
because I never see any data and this never reports any
error.

I have a button that causes the following code to
execute.  This is the only code related to the serial
i/o.  I use char buffer[8] to hold the 7 characters
I receive.

Why wouldn't this code receive the 7 characters?  Have
I missed something?  Is there more setup required?  What
should timeout parameters be?  Don't think that is
the problem however.

// code used in button event handler
SerSettingsType serSettings;
UInt serRefNo;

SysLibFind("Serial Library", &serRefNo);
serError = SerOpen(serRefNo, 0, 19200);
if(serError != 0) {
    FrmCustomAlert(altNotice,"Error", "Open Error", " ");
}
SerGetSettings(serRefNo, &serSettings);
serSettings.flags = 100;
serSettings.baudRate = 19200;
SerSetSettings(serRefNo, &serSettings);
SerReceiveFlush(serRefNo, 30000);
serError = SerReceive(serRefNo, buffer, 6, 10000, &serError);
if(serError != 0)

    FrmCustomAlert(altNotice, "Error", "Receive error.", " ");
}
buffer[7]= 0;                      // terminate received string
SetFieldText(fldTrigger, buffer);  // display received chars
SerClose(serRefNo);
handled = 1;
break;

Any help appreciated.

Mike
--
-----------------------------------------------------------------
Discussion Group:        http://www.halcyon.com/ipscone/wwwboard/

Protect your constitutional rights. Your favorite one may be next!
-----------------------------------------------------------------

--
-----------------------------------------------------------------
Discussion Group:        http://www.halcyon.com/ipscone/wwwboard/

Protect your constitutional rights. Your favorite one may be next!
-----------------------------------------------------------------



Reply via email to