views:

108

answers:

2

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;
+1  A: 

Some things to verify...

Is the NewLine property correct for your modem? The default is a line feed.

How about the RtsEnable and DtrEnable values?

Is the Handshake property correct?

Austin Salonen
+1  A: 

Throws it back? an ATE0 will disable it echoing what you send it.

You should probably also issue an ATQ0 to tell the device you want responses, otherwise it won't issue OKs. (a subsequent ATV1 will make them verbose) also issue a AT+CMEE=1 to activate error responses.

There are also existing libraries that are designed to work with GSM Modems that will save you the trouble, if you want to do it yourself a port monitor will save you pulling out your hair by showing you exactly what being sent/received.

Alex K.