'Open port with current settings. This may throw a SerialException
if the port cannot be opened.'

def open(self):

    if (self._port is None):
        raise SerialException('Port    must    be    configured    before    it    can    be    used.')
    if self.is_open:
        raise SerialException('Port    is    already    open.')
    self.fd = None
    try:
        self.fd = os.open(self.portstr, ((os.O_RDWR | os.O_NOCTTY) | os.O_NONBLOCK))
    except OSError as msg:
        self.fd = None
        raise SerialException(msg.errno, 'could    not    open    port    {}:    {}'.format(self._port, msg))
    try:
        self._reconfigure_port(force_update=True)
    except:
        try:
            os.close(self.fd)
        except:
            pass
        self.fd = None
        raise
    else:
        self.is_open = True
    try:
        if (not self._dsrdtr):
            self._update_dtr_state()
        if (not self._rtscts):
            self._update_rts_state()
    except IOError as e:
        if (e.errno in (errno.EINVAL, errno.ENOTTY)):
            pass
        else:
            raise
    self.reset_input_buffer()
    (self.pipe_abort_read_r, self.pipe_abort_read_w) = os.pipe()
    (self.pipe_abort_write_r, self.pipe_abort_write_w) = os.pipe()
    fcntl.fcntl(self.pipe_abort_read_r, fcntl.F_SETFL, os.O_NONBLOCK)
    fcntl.fcntl(self.pipe_abort_write_r, fcntl.F_SETFL, os.O_NONBLOCK)
