private void Form1_Load(object sender, EventArgs e) { try { p.PortName = "COM9"; p.BaudRate = 460800; p.DataBits = 8; p.StopBits = StopBits.One; p.Parity = Parity.None; p.ReadTimeout = 300; p.WriteTimeout = 300; p.Open(); p.DtrEnable = true; p.RtsEnable = true; } catch (Exception ex) { throw ex; } p.Write("AT\r\n"); String s1 = p.ReadLine(); if (s1.Equals ("OK")) { MessageBox.Show("Port is connected"); } else MessageBox.Show("Port is not connected"); } private void button1_Click(object sender, EventArgs e) { // p.write(""); p.Write("at+cmgf=1\r\n"); p.Write("at+cmgs=\"+919842798108\"\r\n"); p.Write("Test message "); SendKeys.Send("^(z)"); String s2 = p.ReadLine(); if (s2.Equals("OK")) { MessageBox.Show("Message Sent"); } else MessageBox.Show("Message not sent"); } } }
if (s1.Equals ("OK")) { MessageBox.Show("Port is connected"); }
if (s1.Contain ("OK")) { MessageBox.Show("Port is connected"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)