public void OpenConnection(int modemPort) { moRS232.Port = modemPort; moRS232.Open(); moRS232.Dtr = true; moRS232.Rts = true; moRS232.EnableEvents(); RxBuff = new StringBuilder(); }
/// <summary></summary> public void OpenConnection(int port) { moRS232.Port = port; moRS232.Open(); moRS232.Dtr = true; moRS232.Rts = true; moRS232.EnableEvents(); textProgress.Text += "Modem Connection Opened\r\n"; RxBuff = new StringBuilder(); }
// 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; } }