我想使用 C# 从 GSM 调制解调器拨打电话。我已经编写了以下代码。但我无法拨打电话。请告诉错误是什么。还让我知道如何处理来自调制解调器的代码中的响应,以便我可以显示“呼叫连接”或“无法连接”之类的消息。
private void button1_Click(object sender, EventArgs e)
{
SerialPort po = new SerialPort();
po.PortName = "COM3";
po.BaudRate = int.Parse( "9600");
po.DataBits = Convert.ToInt32("8");
po.Parity = Parity.None;
po.StopBits = StopBits.One;
po.ReadTimeout = int.Parse("300");
po.WriteTimeout = int.Parse("300");
po.Encoding = Encoding.GetEncoding("iso-8859-1");
po.Open();
po.DtrEnable = true;
po.RtsEnable = true;
po.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
po.Write("ATD9030665834;");
}
public void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (e.EventType == SerialData.Chars)
{
//what to write here to display the response??
}
}