Пример #1
0
            public void OpenPort()
            {
                StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;

                string[] ports = SerialPort.GetPortNames();
                if (Array.IndexOf(ports, PortNumber) > -1)
                {
                    RS232 = new SerialPort(PortNumber, BaudRate, Parity.None, 8, StopBits.One)
                    {
                        Handshake    = Handshake.None,
                        ReadTimeout  = Timeouts,
                        WriteTimeout = Timeouts
                    };
                    RS232.Open();
                    Continue        = true;
                    readThread      = new Thread(Read);
                    readThread.Name = "Reading Port Thread";
                    readThread.Start();
                }
                else
                {
                    MessageBox.Show("Укажите существующий COM порт или подключите устройство", "COM порт не найден", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Form PortSettingsForm = new PortSettingsForm();
                    PortSettingsForm.ShowDialog();
                }
            }
Пример #2
0
        private void PortSettingsToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            Form PortSettingsForm = new PortSettingsForm();

            PortSettingsForm.ShowDialog();
        }