c# - 在 C# 中从 gsm 调制解调器调用电话

标签 c# serial-port gsm serial-communication telecommunication

我想使用 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??    
    }  
}  

最佳答案

使用 port.WriteLine("ATD"+phno+";");

这肯定能解决你的问题..

并使用 port.ReadExisting() 处理响应并与您的要求进行比较。就这么简单:)

祝你好运..

关于c# - 在 C# 中从 gsm 调制解调器调用电话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11445313/

相关文章:

c# - AutoFac 和 CustomPrincipal

c# - 是否有用于处理 Internet 上的大型数据集的设计模式?

android - 从 HSPA 网络服务的电话获取信号强度 RSCP 和 Ec/Io

android - SIM 上 JavaCard 小程序的可信时间来源

c# - 使用 C# 将字符串转换为 GSM 7 位

c# - 形状与 DrawingVisual 的性能

c# - 如何通过Mono Cecil获取字段的初始值?

python - 在python中读取arduino串行连接

c - 使用 Virtualbox 在主机和 guest 之间建立串行端口连接

linux - 我可以在 Red Hat Linux 上使用串行端口作为 TCP/IP 接口(interface)吗?