Logo Search packages:      
Sourcecode: libserial version File versions  Download package

void SerialStream::SetCharSize ( const SerialStreamBuf::CharSizeEnum  size  ) 

Set the character size associated with the serial port.

Parameters:
size The character size will be set to this value.

Definition at line 98 of file SerialStream.cc.

References LibSerial::SerialStreamBuf::CHAR_SIZE_INVALID, and LibSerial::SerialStreamBuf::SetCharSize().

                                                                     {
    SerialStreamBuf* my_buffer = dynamic_cast<SerialStreamBuf *>(this->rdbuf()) ;
    //
    // Make sure that we are dealing with a SerialStreamBuf before
    // proceeding. This check also makes sure that we have a non-NULL
    // buffer associated with this stream.
    //
    if( my_buffer ) {
        //
        // Try to set the baud rate. If the corresponding function of the
        // SerialStreamBuf class returns BAUD_INVALID, then we have a
        // problem and the stream is no longer valid for I/O.
        //
        if( SerialStreamBuf::CHAR_SIZE_INVALID == my_buffer->SetCharSize(char_size) ) {
            setstate(badbit) ;
        }
    } else {
        //
        // If the dynamic_cast above failed then we either have a NULL
        // streambuf associated with this stream or we have a buffer of
        // class other than SerialStreamBuf. In either case, we have a
        // problem and we should stop all I/O using this stream.
        //
        setstate(badbit) ;
    }
    return ;
}


Generated by  Doxygen 1.6.0   Back to index