title: AT Command Works, But no response
body: <p>I've tried sending AT commands by opening a serial port connection and my goal was to send out an SMS. I was able to achieve this and the message was sent out, which is a sign that the WriteLine() method completes successfully. However, i can't seem to get any response in my receive buffers. I've turned on echo by looking at some of the answers over here on stackoverflow.</p>
  
  <p>But still there is no response. I tried waiting out by using Thread.Sleep() and also by using the handler, p_DataReceived. There is still no response. </p>
  
  <p>One example would be the simple "AT" command which should have a response of "ok". But there are no responses at all (i.e. BytesToRead property size is 0)</p>
  
  <p>I'm trying this with D-Link's dwm222 4G LTE USB adapter</p>
  
  <p>Any pointers would be greatly appreciated !</p>
  
  <pre><code>    private void button_Click(object sender, RoutedEventArgs e)
      {
  
  
  
          mySerialPort = new SerialPort("COM15");
          mySerialPort.BaudRate = 9600;
          mySerialPort.Parity = Parity.None;
          mySerialPort.StopBits = StopBits.One;
          mySerialPort.DataBits = 8;
  
          mySerialPort.Handshake = Handshake.None;
          mySerialPort.NewLine = Environment.NewLine;
  
          mySerialPort.DataReceived += new SerialDataReceivedEventHandler(p_DataReceived);
          mySerialPort.Open();
          mySerialPort.DiscardInBuffer();
          mySerialPort.DiscardOutBuffer();
  
  
          mySerialPort.WriteLine("ATE1"); //turn on echo
  
  
          mySerialPort.WriteLine("AT"); //test response
  
  
          Thread.Sleep(3000);
          string responseSTR = mySerialPort.ReadLine();
  
          if (responseSTR.Contains("OK"))  //empty string
          {
  
              MessageBox.Show(responseSTR);
           }
  
          this.SendSms("+XXXXXXXXXXXXXXXXXXX", "Hello From C#");
  
          mySerialPort.Close();
  
      }
  
      public void p_DataReceived(object sender, SerialDataReceivedEventArgs e)
      {
          string s = (sender as SerialPort).ReadExisting();
          buff += s;
          MessageBox.Show(buff);
      }
  
     void SendSms(string destination, string text)
      { ........}
  </code></pre>