Esempio n. 1
0
        private void Connect()
        {
            if (m_serialClient != null)
            {
                Disconnect();
            }

            string connectionString =
                "port=" + ComboBoxSerialPorts.Text +
                "; baudrate=" + ComboBoxSerialBaudRates.Text +
                "; parity=" + ComboBoxSerialParities.Text +
                "; stopbits=" + ComboBoxSerialStopBits.Text +
                "; databits=" + TextBoxSerialDataBits.Text +
                "; dtrenable=" + CheckBoxSerialDTR.Checked.ToString() +
                "; rtsenable=" + CheckBoxSerialRTS.Checked.ToString();

            // Wire up serial client events
            m_serialClient = new SerialClient();
            m_serialClient.SettingsCategory       = ComboBoxSerialPorts.Text;
            m_serialClient.ConnectionAttempt     += m_serialClient_ConnectionAttempt;
            m_serialClient.ConnectionEstablished += m_serialClient_ConnectionEstablished;
            m_serialClient.ConnectionException   += m_serialClient_ConnectionException;
            m_serialClient.ConnectionTerminated  += m_serialClient_ConnectionTerminated;
            m_serialClient.ReceiveDataComplete   += m_serialClient_ReceiveDataComplete;
            m_serialClient.ReceiveDataException  += m_serialClient_ReceiveDataException;
            m_serialClient.SendDataComplete      += m_serialClient_SendDataComplete;
            m_serialClient.SendDataException     += m_serialClient_SendDataException;
            m_serialClient.ConnectionString       = connectionString;
            m_serialClient.ConnectAsync();
        }
Esempio n. 2
0
        private void Connect()
        {
            if (m_serialClient != null)
                Disconnect();

            string connectionString =
                            "port=" + ComboBoxSerialPorts.Text +
                            "; baudrate=" + ComboBoxSerialBaudRates.Text +
                            "; parity=" + ComboBoxSerialParities.Text +
                            "; stopbits=" + ComboBoxSerialStopBits.Text +
                            "; databits=" + TextBoxSerialDataBits.Text +
                            "; dtrenable=" + CheckBoxSerialDTR.Checked.ToString() +
                            "; rtsenable=" + CheckBoxSerialRTS.Checked.ToString();

            // Wire up serial client events
            m_serialClient = new SerialClient();
            m_serialClient.SettingsCategory = ComboBoxSerialPorts.Text;
            m_serialClient.ConnectionAttempt += m_serialClient_ConnectionAttempt;
            m_serialClient.ConnectionEstablished += m_serialClient_ConnectionEstablished;
            m_serialClient.ConnectionException += m_serialClient_ConnectionException;
            m_serialClient.ConnectionTerminated += m_serialClient_ConnectionTerminated;
            m_serialClient.ReceiveDataComplete += m_serialClient_ReceiveDataComplete;
            m_serialClient.ReceiveDataException += m_serialClient_ReceiveDataException;
            m_serialClient.SendDataComplete += m_serialClient_SendDataComplete;
            m_serialClient.SendDataException += m_serialClient_SendDataException;
            m_serialClient.ConnectionString = connectionString;
            m_serialClient.ConnectAsync();
        }