Esempio n. 1
0
 private void HandleConnection()
 {
     /* Initialize port options */
     SerialPort.BaudRate    = BaudrateFromUI();
     SerialPort.DataBits    = DatabitsFromUI();
     SerialPort.Parity      = ParityFromUI();
     SerialPort.StopBits    = StopbitsFromUI();
     SerialPort.Handshake   = HandshakeFromUI();
     SerialPort.ReadTimeout = 50;
     SerialPort.PortName    = (string)comPortCb.SelectedValue;
     try
     {
         SerialPort.Open();
         if (SerialPort.IsOpen == true)
         {
             SerialPort.BeginRead();
             miscData.ErrorString = "Connected";
             connectBtn.Text      = "Disconnect";
             comPortCb.Enabled    = false;
         }
     } catch (IOException ioEx)
     {
     }
 }