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;
}

Reply via email to