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

const SerialStreamBuf::FlowControlEnum SerialStreamBuf::FlowControl (  )  const

Return the current flow control setting.

Definition at line 611 of file SerialStreamBuf.cc.

References CTRL_Q, CTRL_S, FLOW_CONTROL_HARD, FLOW_CONTROL_INVALID, FLOW_CONTROL_NONE, FLOW_CONTROL_SOFT, and mFileDescriptor.

Referenced by LibSerial::SerialStream::FlowControl(), and SetFlowControl().

                                   {
    if( -1 == mFileDescriptor ) {
        return FLOW_CONTROL_INVALID ;
    }
    //
    // Get the current terminal settings.
    //
    struct termios tset ;
    if( -1 == tcgetattr(mFileDescriptor, &tset) ) {
        return FLOW_CONTROL_INVALID ;
    }
    //
    // Check if IXON and IXOFF are set in c_iflag. If both are set and
    // VSTART and VSTOP are set to 0x11 (^Q) and 0x13 (^S) respectively,
    // then we are using software flow control.
    //
    if( (tset.c_iflag & IXON)         &&
        (tset.c_iflag & IXOFF)        &&
        (CTRL_Q == tset.c_cc[VSTART]) &&
        (CTRL_S == tset.c_cc[VSTOP] ) ) {
        return FLOW_CONTROL_SOFT ;
    } else if ( ! ( (tset.c_iflag & IXON) ||
                    (tset.c_iflag & IXOFF) ) ) {
        if ( tset.c_cflag & CRTSCTS ) {
            //
            // If neither IXON or IXOFF is set then we must have hardware flow
            // control.
            //
            return FLOW_CONTROL_HARD ;
        } else {
            return FLOW_CONTROL_NONE ;
        }
    }
    //
    // If none of the above conditions are satisfied then the serial
    // port is using a flow control setup which we do not support at
    // present.
    //
    return FLOW_CONTROL_INVALID ;
}


Generated by  Doxygen 1.6.0   Back to index