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

streambuf::int_type SerialStreamBuf::overflow ( int_type  c  )  [protected, virtual]

Writes the specified character to the associated serial port.

Returns:
The character c.

Definition at line 973 of file SerialStreamBuf.cc.

References mFileDescriptor.

                                    {
    //
    // If we do not have a valid file descriptor then we cannot do much
    // here.
    //
    if( -1 == mFileDescriptor ) {
        return traits_type::eof() ;
    }
    //
    // Try to write the specified character to the serial port. 
    //
    if ( traits_type::eq_int_type( c, traits_type::eof()) ) {
        //
        // If c is the eof character then we do nothing. 
        //
        return traits_type::eof() ;
    } else {
        //
        // Otherwise we write the character to the serial port. 
        //
        char out_ch = traits_type::to_char_type(c) ;
        ssize_t retval = write(mFileDescriptor, &out_ch, 1) ;
        //
        // If the write failed then return eof. 
        //
        if( (-1 == retval) ||
            ( 0 == retval) ) {
            return traits_type::eof() ;
        }
        //
        // Otherwise, return something other than eof().
        //
        return traits_type::not_eof(c) ;
    }
}


Generated by  Doxygen 1.6.0   Back to index