Ejemplo n.º 1
0
 public void SetOpenPort(bool open)
 {
     try
     {
         if (open == true)
         {
             _serial.Open();
         }
         else
         {
             _serial.Close();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
        public MainForm()
        {
            InitializeComponent();
            try
            {
                _serial             = new SerialPort3964r(false);
                _serial.PortName    = "COM9";
                _serial.BaudRate    = 9600;
                _serial.ReadTimeout = 1000;
                _serial.Open();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            _data = new byte[3];

            myThread = new Thread(new ThreadStart(ThreadLoop));
            myThread.Start();
        }
Ejemplo n.º 3
0
 private void BtConnect_Click(object sender, EventArgs e)
 {
     try
     {
         //Propriétés du port COM
         _serial.PortName = CbPort.Text;                   //Port COM choisi;
         _serial.BaudRate = Int32.Parse(this.CbBaud.Text); // Baud rate choisi
         //_serial.ReadTimeout = 1000;
         _serial.Parity          = System.IO.Ports.Parity.None;
         _serial.StopBits        = System.IO.Ports.StopBits.One;
         _serial.DataBits        = 8;
         _serial.WriteBufferSize = 2048;
         _serial.ReadBufferSize  = 4096;
         //_serial.WriteTimeout = -1;
         //_serial.ReadTimeout = 50;
         _serial.Open();
         BtConnect.Enabled    = false;    //Désactiver le bouton "Connect"
         BtDisconnect.Enabled = true;     //Activer le bouton "Disconnect"
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }