如何在C#中使用AT后发送DTMF命令? [英] How to send DTMF commands after using AT in C#?

查看:56
本文介绍了如何在C#中使用AT后发送DTMF命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要从USB调制解调器拨打一个号码,在另一方接听电话后我需要发送几个DTMF​​命令。我试图做这个代码 - 但是当我尝试发送DTMF时退出调用:

I need to dial a number from USB modem, after other side answer the call I need to send several DTMF commands. I have tried to do this code - But it exit the call when I try to send DTMF:

 SerialPort port = new SerialPort("COM7", 115200);
        port.Open();
        port.ReadTimeout = 1000000;
        port.NewLine = "\r";
        port.WriteLine("ATZ"); // reset the modem
        //port.ReadTo("OK\r\n"); // wait for "OK" from modem

        port.WriteLine("ATDT 123456789"); // dial number with dialtone
        port.WriteLine("AT+VTS 2"); // dial DTMF

        string response = port.ReadTo("\r").Trim(); // read until first newline
        port.Close();

推荐答案

看起来不错。我会将第一个命令添加为"AAAT"。大多数调制解调器可以使用此命令将自己与传入的字符流同步。在发送您的命令后等待"确定"。等待单个 " \ r"
是不够的,因为调制解调器将回显您发送给它的相同字符,因此在调制解调器处理了您发送的命令之前,您将在自己的WriteLine末尾看到\ r。


It looks good. I would add as a first command an "AAAT". Most modems can use this for synchronizing themselves with the incoming character stream. Wait for an "OK" after sending your commands. Waiting for a single "\r" is not enough because the modem will echo the same characters that you send to it, and therefore you will see the \r from the end of your own WriteLine before the modem has processed the command that you sent.


这篇关于如何在C#中使用AT后发送DTMF命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆