Ejemplo n.º 1
0
    // This subroutine sends an AT command to the modem, and records its response.
    //   It depends on the timer to do the reading of the response.

    private void btnSendATCommand_Click(object sender, System.EventArgs e)
    //btnSendATCommand.Click;
    {
        // Always wrap up working with Comm Ports in exception handlers.

        try
        {
            // Enable the timer.

            this.tmrReadCommPort.Enabled = true;

            // Attempt to open the port.

            m_CommPort.Open(m_ModemPort, 115200, 8, Rs232.DataParity.Parity_None,
                            Rs232.DataStopBit.StopBit_1, 4096);

            // Write an AT Command to the Port.

            m_CommPort.Write(Encoding.ASCII.GetBytes("AT" + "\r"));

            // Sleep long enough for the modem to respond and the timer to fire.

            System.Threading.Thread.Sleep(200);

            Application.DoEvents();

            m_CommPort.Close();
        }
        catch (Exception ex)
        {
            // Warn the user.

            MessageBox.Show("Unable to communicate with Modem");
        }
        finally
        {
            // Disable the timer.

            this.tmrReadCommPort.Enabled = false;
        }
    }
Ejemplo n.º 2
0
 /// <summary></summary>
 public void CloseConnection()
 {
     textProgress.Text += "Modem Connection Closed\r\n";
     ScrollProgress();
     moRS232.Close();
 }
Ejemplo n.º 3
0
 public void CloseConnection()
 {
     moRS232.Close();
 }