/// <summary>
 /// Sets the serial port options.
 /// </summary>
 /// <param name="portname">Portname.</param>
 /// <param name="baudrate">Baudrate.</param>
 public void SetPort(string portname, int baudrate = 115200, Handshake handshake = Handshake.None)
 {
     if (!string.IsNullOrEmpty(_portName) && _portName != portname)
     {
         // Port changed, set to error so that the connection watcher will reconnect
         // using the new port
         //_gotReadWriteError = true;
         Connect();
     }
     _portName        = portname;
     _defaultBaudRate = baudrate;
     _handshake       = handshake;
     //_readerTaskTimeWait = readerTaskTime;
 }
 public SerialPortInput(string portName,
                        int baudRate,
                        Parity parity,
                        int dataBits,
                        StopBits stopBits,
                        Handshake handshake,
                        bool isVirtualPort,
                        //int readerTaskTime = 100,
                        bool useStream   = false,
                        int writeTimeout = SerialPort.InfiniteTimeout,
                        int readTimeout  = SerialPort.InfiniteTimeout)
 {
     _isVirtualPort   = isVirtualPort;
     _defaultBaudRate = baudRate;
     _defaultParity   = parity;
     _defaultDataBits = dataBits;
     _defaultStopBits = stopBits;
     _portName        = portName;
     _handshake       = handshake;
     _useStream       = useStream;
     _writeTimeout    = writeTimeout;
     _readTimeout     = readTimeout;
 }