Exemplo n.º 1
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     this.ComPort.PortName = Convert.ToString(this.cboPorts.Text);
     this.ComPort.BaudRate = Convert.ToInt32(this.cboBaudRate.Text);
     this.ComPort.DataBits = 8;
     this.ComPort.StopBits = StopBits.One;
     this.ComPort.Parity   = Parity.None;
     this.ComPort.NewLine  = "\r";
     try
     {
         this.ComPort.Open();
         if (!this.ComPort.IsOpen)
         {
             return;
         }
         this.tbReceived.Clear();
         this.emulator           = new ELM(this.ComPort, this);
         this.btnConnect.Enabled = false;
         this.btnClose.Enabled   = true;
     }
     catch (Exception ex)
     {
         int num = (int)MessageBox.Show("Could not open port. Message: " + ex.Message);
     }
 }
Exemplo n.º 2
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     if (this.ComPort.IsOpen)
     {
         this.ComPort.Close();
         this.emulator = (ELM)null;
     }
     this.btnClose.Enabled   = false;
     this.btnConnect.Enabled = true;
 }