Example #1
0
        private void OnTerminalProcessTerminated(object sender, EventArgs eventArgs)
        {
            m_TerminalProcess = null;

            var message = "Terminal application exited.";

            _Logger.Info(message);
            errorLabel.Invoke(new Action(() => { errorLabel.Text = message; }));
        }
Example #2
0
        private void OnFormClosing(object sender, FormClosingEventArgs e)
        {
            _Logger.Info("Application closing.");

            SerialPortService.CleanUp();

            if (m_TerminalProcess != null)
            {
                m_TerminalProcess.Disconnect();
                m_TerminalProcess = null;
            }
        }
Example #3
0
        private void HandleSerialPortsChange(string[] serialPorts)
        {
            // Are we connected to a port that went away?
            if ((m_TerminalProcess != null) && (!serialPorts.Contains(m_SelectedSerialPort)))
            {
                _Logger.Info("Serial port " + m_SelectedSerialPort + " disconnected.  Closing Terminal Application.");
                m_TerminalProcess.Disconnect();
                m_TerminalProcess = null;
                errorLabel.Text   = "Modem disconnected; terminal application closed.";
            }

            // Don't connect if already connected and unless the user requests it.
            if ((m_TerminalProcess == null) && autoConnectCheckBox.Checked && (serialPorts.Length == 1))
            {
                m_TerminalProcess = new TerminalProcess();
                m_TerminalProcess.ProcessTerminated += OnTerminalProcessTerminated;
                m_SelectedSerialPort = serialPorts[0];

                var comPortNumber = Convert.ToInt32(Regex.Replace(m_SelectedSerialPort, "[^0-9]", "")).ToString();

                if (!String.IsNullOrEmpty(m_Config.PortNumber))
                {
                    comPortNumber = m_Config.PortNumber;
                }

                string arguments = m_Config.PortOption + m_Config.PortPrefix + comPortNumber;
                arguments += " " + m_Config.BaudRateOption + m_Config.BaudRate;
                arguments += " " + m_Config.ExtraArgs;

                if (!m_TerminalProcess.Connect(m_Config.TerminalApplicationPath, arguments))
                {
                    errorLabel.Text = "Error: Unable to launch: " + m_Config.TerminalApplicationPath;
                }
                else
                {
                    errorLabel.Text = "Connected to terminal application.  You may need to press ENTER there.";
                }
            }
        }