3

I tried to send commands to a GSM modem or phone with C# using this code but it`s not working! Can anybody tell me what should I do ?

SerialPort sp = new SerialPort();
sp.PortName = "COM42";
sp.Open();
sp.Write("ATD09364191752");
abatishchev
  • 98,240
  • 88
  • 296
  • 433
mahdi
  • 16,257
  • 15
  • 52
  • 73
  • that hasn't anything to do with c#, you should look up for a dictionary for at commands, and also how a sms has to be encoded – user287107 Nov 21 '10 at 22:54

2 Answers2

3
  1. You are not writing a newline after the ATD command. (I think you have to.)
  2. You don't call sp.Flush(), so the command may be getting stuck in a buffer. Try adding this call after the Write() call.
cdhowie
  • 158,093
  • 24
  • 286
  • 300
  • Not flush. Yes on the newline, use WriteLine(). A bit fuzzy on a country where a phone number starts with a zero and doesn't have enough digits to make an international call :) – Hans Passant Nov 21 '10 at 23:08
2

You are relying on all default settings for baud-rate, handshake protocols etc. You may want to check the modem docs about those.

H H
  • 263,252
  • 30
  • 330
  • 514