Logo Search packages:      
Sourcecode: qmk-groundstation version File versions  Download package

void Win_QextSerialPort::setStopBits ( StopBitsType  stopBits  )  [virtual]

Sets the number of stop bits used by the serial port. Possible values of stopBits are:

		STOP_1      1 stop bit
		STOP_1_5    1.5 stop bits
		STOP_2      2 stop bits
		

Note:
This function is subject to the following restrictions:
2 stop bits cannot be used with 5 data bits.
1.5 stop bits cannot be used with 6 or more data bits.
POSIX does not support 1.5 stop bits.

Implements QextSerialBase.

Definition at line 549 of file win_qextserialport.cpp.

Referenced by open(), and Win_QextSerialPort().

                                                          {
      LOCK_MUTEX();
      if (Settings.StopBits!=stopBits) {
            if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) ||
                        (stopBits==STOP_1_5 && Settings.DataBits!=DATA_5)) {
                        }
            else {
                  Settings.StopBits=stopBits;
            }
      }
      if (isOpen()) {
            switch (stopBits) {
                        
                        /*one stop bit*/
                  case STOP_1:
                        Win_CommConfig.dcb.StopBits=ONESTOPBIT;
                        SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
                        break;
                        
                        /*1.5 stop bits*/
                  case STOP_1_5:
                        TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: 1.5 stop bit operation is not supported by POSIX.");
                        if (Settings.DataBits!=DATA_5) {
                              TTY_WARNING("Win_QextSerialPort: 1.5 stop bits can only be used with 5 data bits");
                        }
                        else {
                              Win_CommConfig.dcb.StopBits=ONE5STOPBITS;
                              SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
                        }
                        break;
                        
                        /*two stop bits*/
                  case STOP_2:
                        if (Settings.DataBits==DATA_5) {
                              TTY_WARNING("Win_QextSerialPort: 2 stop bits cannot be used with 5 data bits");
                        }
                        else {
                              Win_CommConfig.dcb.StopBits=TWOSTOPBITS;
                              SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
                        }
                        break;
                  }
      }
      UNLOCK_MUTEX();
}


Generated by  Doxygen 1.6.0   Back to index