'Set communication parameters on opened port.'

def _reconfigure_port(self):

    if (not self._port_handle):
        raise SerialException('Can    only    operate    on    a    valid    port    handle')
    if (self._timeout is None):
        self._port_handle.ReadTimeout = System.IO.Ports.SerialPort.InfiniteTimeout
    else:
        self._port_handle.ReadTimeout = int((self._timeout * 1000))
    if (self._write_timeout is None):
        self._port_handle.WriteTimeout = System.IO.Ports.SerialPort.InfiniteTimeout
    else:
        self._port_handle.WriteTimeout = int((self._write_timeout * 1000))
    try:
        self._port_handle.BaudRate = self._baudrate
    except IOError as e:
        raise ValueError(str(e))
    if (self._bytesize == FIVEBITS):
        self._port_handle.DataBits = 5
    elif (self._bytesize == SIXBITS):
        self._port_handle.DataBits = 6
    elif (self._bytesize == SEVENBITS):
        self._port_handle.DataBits = 7
    elif (self._bytesize == EIGHTBITS):
        self._port_handle.DataBits = 8
    else:
        raise ValueError(('Unsupported    number    of    data    bits:    %r' % self._bytesize))
    if (self._parity == PARITY_NONE):
        self._port_handle.Parity = getattr(System.IO.Ports.Parity, 'None')
    elif (self._parity == PARITY_EVEN):
        self._port_handle.Parity = System.IO.Ports.Parity.Even
    elif (self._parity == PARITY_ODD):
        self._port_handle.Parity = System.IO.Ports.Parity.Odd
    elif (self._parity == PARITY_MARK):
        self._port_handle.Parity = System.IO.Ports.Parity.Mark
    elif (self._parity == PARITY_SPACE):
        self._port_handle.Parity = System.IO.Ports.Parity.Space
    else:
        raise ValueError(('Unsupported    parity    mode:    %r' % self._parity))
    if (self._stopbits == STOPBITS_ONE):
        self._port_handle.StopBits = System.IO.Ports.StopBits.One
    elif (self._stopbits == STOPBITS_ONE_POINT_FIVE):
        self._port_handle.StopBits = System.IO.Ports.StopBits.OnePointFive
    elif (self._stopbits == STOPBITS_TWO):
        self._port_handle.StopBits = System.IO.Ports.StopBits.Two
    else:
        raise ValueError(('Unsupported    number    of    stop    bits:    %r' % self._stopbits))
    if (self._rtscts and self._xonxoff):
        self._port_handle.Handshake = System.IO.Ports.Handshake.RequestToSendXOnXOff
    elif self._rtscts:
        self._port_handle.Handshake = System.IO.Ports.Handshake.RequestToSend
    elif self._xonxoff:
        self._port_handle.Handshake = System.IO.Ports.Handshake.XOnXOff
    else:
        self._port_handle.Handshake = getattr(System.IO.Ports.Handshake, 'None')
