I want to receive message through gsm modem in C#.I have written a code but on console I get continuous stream of ERROR whenever a message is received.Please help me in receiving a message.Here is my code.
static void Main(string[] args)
{
SerialPort serialport = new SerialPort();
int mSpeed = 1;
serialport.PortName = "COM16";
serialport.BaudRate = 9600;
serialport.Parity = Parity.None;
serialport.DataBits = 8;
serialport.StopBits = StopBits.One;
serialport.Handshake = Handshake.XOnXOff;
serialport.DtrEnable = true;
serialport.RtsEnable = true;
serialport.NewLine = Environment.NewLine;
serialport.DataReceived += newSerialDataReceivedEventHandler(DataReceivedHandler);
serialport.Open();
Console.ReadKey();
}
private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
{
SerialPort sp = (SerialPort)sender;
sp.WriteLine("AT+CMTI" + Environment.NewLine);
Console.WriteLine(sp.ReadLine());
}
}
serialport.Open();
– rene