i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check SerialPort Exist Modem ?
06-20-2015, 02:35 PM
Post: #1
Check SerialPort Exist Modem ?
In C# 2005, I used the Nokia E63, I want to check SerialPort Exist Modem, While it run does not get run COM port, you see my code

Code:
private void btnGetPort_Click(object sender, EventArgs e)
        {
            cmbPort.Items.Clear();
            foreach (string portName in SerialPort.GetPortNames())
            {
                try
                {
                    using (SerialPort sp = new SerialPort(portName, 9600))
                    {
                        if (!(sp.IsOpen)) sp.Open();
                        sp.DiscardInBuffer();
                        sp.DiscardOutBuffer();
                        sp.Write("AT\r\n");
                        System.Threading.Thread.Sleep(100);
                        string response = sp.ReadExisting();
                        if (response == "OK")
                        {
                            cmbPort.Items.Add(portName);
                        }
                    }
                }
                catch (Exception ex)
                {
                    continue;
                }
            }
        }



Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  How to check column name exist in DataTable nisar87 0 7,167 10-31-2012 07:13 AM
Last Post: nisar87



User(s) browsing this thread: 1 Guest(s)