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

void Win_QextSerialPort::setDataBits ( DataBitsType  dataBits  )  [virtual]

Sets the number of data bits used by the serial port. Possible values of dataBits are:

		DATA_5      5 data bits
		DATA_6      6 data bits
		DATA_7      7 data bits
		DATA_8      8 data bits
		

Note:
This function is subject to the following restrictions:
5 data bits cannot be used with 2 stop bits.
1.5 stop bits can only be used with 5 data bits.
8 data bits cannot be used with space parity on POSIX systems.

Implements QextSerialBase.

Definition at line 470 of file win_qextserialport.cpp.

Referenced by open(), and Win_QextSerialPort().

                                                          {
      LOCK_MUTEX();
      if (Settings.DataBits!=dataBits) {
            if ((Settings.StopBits==STOP_2 && dataBits==DATA_5) ||
                        (Settings.StopBits==STOP_1_5 && dataBits!=DATA_5)) {
                        }
            else {
                  Settings.DataBits=dataBits;
            }
      }
      if (isOpen()) {
            switch(dataBits) {
                        
                        /*5 data bits*/
                  case DATA_5:
                        if (Settings.StopBits==STOP_2) {
                              TTY_WARNING("Win_QextSerialPort: 5 Data bits cannot be used with 2 stop bits.");
                        }
                        else {
                              Win_CommConfig.dcb.ByteSize=5;
                              SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
                        }
                        break;
                        
                        /*6 data bits*/
                  case DATA_6:
                        if (Settings.StopBits==STOP_1_5) {
                              TTY_WARNING("Win_QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits.");
                        }
                        else {
                              Win_CommConfig.dcb.ByteSize=6;
                              SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
                        }
                        break;
                        
                        /*7 data bits*/
                  case DATA_7:
                        if (Settings.StopBits==STOP_1_5) {
                              TTY_WARNING("Win_QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits.");
                        }
                        else {
                              Win_CommConfig.dcb.ByteSize=7;
                              SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
                        }
                        break;
                        
                        /*8 data bits*/
                  case DATA_8:
                        if (Settings.StopBits==STOP_1_5) {
                              TTY_WARNING("Win_QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits.");
                        }
                        else {
                              Win_CommConfig.dcb.ByteSize=8;
                              SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
                        }
                        break;
                  }
      }
      UNLOCK_MUTEX();
}


Generated by  Doxygen 1.6.0   Back to index