Off the top of my head....
The serial port needs a certain amount of time to power up and initialize
(at least for 2.0 and 3.0 Palms). If you try to send data too soon, you may
get strange results. I typically wait around 30ms before transmitting. The
Pro/Personal send a startup char during the port initialization, I believe
this char is the backspace char (0x08). Other than that, I have not had much
trouble transmitting chars.
Looking at your code, you may want to use a call to SerSendWait (after
SerSend) until you are sure all chars have been sent before shutting down
the port. If you don't, the buffer may loose some of the chars that you
wish to transmit (and this may be where your extra byte is coming from...not
the palm, but your PC-side app that is buffering some extra bits into a new
byte - 0xFF)
SerOpen(...);
SerSend(...);
SerSendWait(...);
SerClose(...);
-----Original Message-----
From: Michael McFarland <[EMAIL PROTECTED]>
To: 'Palm Development List' <[EMAIL PROTECTED]>
Date: Wednesday, July 28, 1999 1:05 PM
Subject: serSend problems...
> I'm suddenly finding that every time I send a string using serSend, the
>final character of the string is replaced with 0xFF. If I send "abcde", on
>the other end of the connection, I get "abcd" and a 0xFF byte. If I send
>"x" specifying to send 1 byte, only a 0xFF is received. If I send "x"
>specifying 2 bytes, I get the 'x' followed by a 0xFF. I've been told
>before that the extra byte might be something generated every time the
>serial port powers up or down, and that its value can vary. Is there any
>truth to this?
>
> I've included some code, so that if I'm doing something blatantly stupid
>somebody might point it out to me. I've tried pasting this function into a
>basic, simple start app, and see the same results. Thanks again to
>everyone who's been so helpful on the list.
>
> Michael
>
>
>static UInt sendSerialString() {
> ULong numSent;
> Long timeout;
> Err err;
>
> timeout = SysTicksPerSecond () * 2; // (was 1/2)2 sec inter-byte timeout
>
> err = SerOpen (SerialLibRefnum, 0/*port*/, 9600/*baud*/);
> if ( err == serErrAlreadyOpen ) {
> err = SerClose (SerialLibRefnum); // we don't want to share or disrupt
> FrmAlert(SerialAlreadyOpenAlert);
> return -1;
> }
>
> numSent = SerSend(SerialLibRefnum, "abcde", 5, &err);
>// numSent = SerSend(SerialLibRefnum, "x", 1, &err);
>// numSent = SerSend(SerialLibRefnum, "x", 2, &err);
> if ( err == serErrLineErr ) {
> SerClearErr (SerialLibRefnum);
> }
> err = SerClose(SerialLibRefnum);
> return 0;
>}
>
>