Exemplo n.º 1
0
        void osf_SerialSelected(OpenSerialForm.SerialSelectedEventArgs e)
        {
            // set the conf of the serial
            serialPort.PortName = e.Port;
            serialPort.BaudRate = e.Rate;

            try
            {
                serialPort.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace + ": " + ex.Message);
                uiconsole.WriteLine(ex.StackTrace + ": " + ex.Message);
                _continue = false;
                return;
            }

            try
            {
                _continue = true;

                if (readThread==null)
                    readThread = new Thread(Read);

                // check if the thread have be stoped
                if (readThread.ThreadState == System.Threading.ThreadState.Aborted || readThread.ThreadState == System.Threading.ThreadState.Stopped)
                {
                    readThread = new Thread(Read);
                    readThread.Priority = ThreadPriority.Highest;
                    readThread.Start();
                }
                else
                    readThread.Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace + ": " + ex.Message);
                uiconsole.WriteLine(ex.StackTrace + ": " + ex.Message);
                serialPort.Close();
                _continue = false;
                return;
            }

            // flag the connection
            uiconsole.WriteLine("Serial Connected");
        }
Exemplo n.º 2
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     OpenSerialForm osf = new OpenSerialForm();
     osf.SerialSelected += osf_SerialSelected;
     osf.ShowDialog();
 }
Exemplo n.º 3
0
        void osf_SerialSelected(OpenSerialForm.SerialSelectedEventArgs e)
        {
            var cam = new Cameras(e.Port, e.Rate)
            {
                CameraName = "Camera",
                Position = new Point()
            };

            listBox1.Items.Add(cam);

            // Start the streaming
            cam.Start();
        }