示例#1
0
 private void Connect_Click(object sender, EventArgs e)
 {
     EcuIsLinked = EcuConnectionF.ECULINKStatus1;
     if (EcuIsLinked)
     {
         MessageBox.Show("串口已连接!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             GobalSerialPort.initGobalSerialPort();
             log.Info("串口是否被被打开:" + GobalSerialPort.SerialPort.IsOpen);
             GobalSerialPort.SerialPort.Open();
             ThreadEcuConnet();
         }
         catch
         {
             showBox1.Text = "串口连接失败!";
         }
     }
 }