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

bool Posix_QextSerialPort::open ( OpenMode  mode = 0  )  [virtual]

Opens the serial port associated to this class. This function has no effect if the port associated with the class is already open. The port is also configured to the current settings, as stored in the Settings structure.

Implements QextSerialBase.

Definition at line 816 of file posix_qextserialport.cpp.

References setBaudRate(), setDataBits(), setFlowControl(), setParity(), setStopBits(), and setTimeout().

{
      LOCK_MUTEX();
      if (mode == QIODevice::NotOpen)
            return isOpen();
      if (!isOpen()) {
            /*open the port*/
            Posix_File->setFileName(port);
            if (Posix_File->open(QIODevice::ReadWrite|QIODevice::Unbuffered)) {
                  /*set open mode*/
                  QIODevice::open(mode);
                  
                  /*configure port settings*/
                  tcgetattr(Posix_File->handle(), &Posix_CommConfig);
                  
                  /*set up other port settings*/
                  Posix_CommConfig.c_cflag|=CREAD|CLOCAL;
                  Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
                  Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
                  Posix_CommConfig.c_oflag&=(~OPOST);
                  Posix_CommConfig.c_cc[VMIN]=0;
                  Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE;
                  Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE;
                  Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE;
                  Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE;
                  Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE;
                  setBaudRate(Settings.BaudRate);
                  setDataBits(Settings.DataBits);
                  setParity(Settings.Parity);
                  setStopBits(Settings.StopBits);
                  setFlowControl(Settings.FlowControl);
                  setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
                  tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
            } else {
            }
      }
      UNLOCK_MUTEX();
      return isOpen();
}


Generated by  Doxygen 1.6.0   Back to index