[C#] SerialPort not taking input. It throws it back at me!
- by Mashew
When I try to write an AT command to my GSM modem, it does not seem to take the command. I have used PuTTY to check that the command words, it does. I have checked to see if the port is opening, it does.
What could I possibly be doing wrong?
NOTE: The "lol" part is for debugging purposes. ;3
SerialPort sp = new SerialPort("COM3");
sp.BaudRate = 9600;
sp.DataBits = 8;
sp.StopBits = StopBits.One;
sp.Parity = Parity.None;
sp.Open();
if (sp.IsOpen == false)
{
sp.Open();
}
Thread.Sleep(1000);
sp.WriteLine("AT+CMGF=1");
Thread.Sleep(1000);
string lol = sp.ReadExisting();
sp.Close();
return lol;