On Mon, 27 Sep 1999, Dave Lippincott wrote:
> 1) I would reduce the timeout value in SerReceiveFlush to something
> smaller,. (unless your chars are being transmitted 1 every 2-3 secs)
What is the purpose of the timeout? I thought that it was a time that
was set to return from the routine, in case data was not received, to
prevent hanging. If it is too long, I wait needlessly. If it is too
short, I return before all chars are input. Correct? At 19,200 I
should receive characters at the rate of two every milli-second or
something like that. What is timeout spec'd in (tics, milli, etc)?
> 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.
Relating to this: I don't see anything about power consumption. If I
have an app that is open for some time, should I use SerOpen in, say,
StartApplication and SerClose in StopApplication then SerReceive with
a button push. Or, should the button push Open, Receive, Close all
in the same function? I guess a better way of asking this is when does
power start to be used; upon Open or Receive?
> 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)
Hmmm...
> 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.
Actually, I would prefer to get the characters one at a time. It suits
my needs better. I used 7 chars, as an example, but the real number is
a repeated string of 130 chars.
One last thing, is there a way to get these characters on with an event
handler or do I have to just sit and poll for them.
Thanks
Mike
>
> -----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!
> -----------------------------------------------------------------
>
>
>
>
>
----------------------------------------------------
Shoot-to-Win
Protect the 2nd Amendment
----------------------------------------------------