public void Dial(string phone) { moRS232.PurgeBuffer(Rs232.PurgeBuffers.TxClear | Rs232.PurgeBuffers.RXClear); string str = "ATDT" + phone + "\r\n"; moRS232.Write(str); }
/// <summary></summary> public void Dial(string phone) { moRS232.PurgeBuffer(Rs232.PurgeBuffers.TxClear | Rs232.PurgeBuffers.RXClear); string str = "ATDT" + phone + "\r\n"; textTx.Text += str; textProgress.Text += "Dialed: " + phone + "\r\n"; moRS232.Write(str); }
// 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; } }
/******************************************************************* * * start * *******************************************************************/ private void btnStart_Click(object sender, EventArgs e) { textBox2.Focus(); textBox4.Focus(); btnCancel.Focus(); btnSave.Focus(); on_flag = true; cancel_flag = false; btnStart.Enabled = false; btnCancel.Enabled = true; btnJudgment.Enabled = true; btnSave.Enabled = false; textBox3.Text = null; comboBox1.Enabled = false; pictureBox1.Image = Image.FromFile(ImageDir + "robot.png"); int buf_count = 0; byte[] buf = new byte[1]; buf[0] = (byte)'s'; buf_count = SerialObj.Write(buf, 0, 1); inputThread = new Thread(ReadInput); inputThread.Priority = ThreadPriority.Highest; inputThread.Start(); for (int count = 0; count <= SIZE; count++) { raw_array[count] = 0; double_raw_array[count] = 0; } Counter = 0; sw.Reset(); sw.Start(); }