how to use AT-Command in C#
-
27-09-2019 - |
Question
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");
Solution
- You are not writing a newline after the ATD command. (I think you have to.)
- You don't call
sp.Flush()
, so the command may be getting stuck in a buffer. Try adding this call after theWrite()
call.
OTHER TIPS
You are relying on all default settings for baud-rate, handshake protocols etc. You may want to check the modem docs about those.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow